home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / os2 / adaptor.zip / ADAPT.ZIP / adaptor / src / wanalysi.c < prev    next >
Text File  |  1994-01-03  |  64KB  |  2,751 lines

  1. # include "Analysi.h"
  2. # include "yyAAnaly.w"
  3. # include <stdio.h>
  4. # if defined __STDC__ | defined __cplusplus
  5. #  include <stdlib.h>
  6. # else
  7.    extern void exit ();
  8. # endif
  9. # include "Tree.h"
  10. # include "Definiti.h"
  11.  
  12. # ifndef NULL
  13. # define NULL 0L
  14. # endif
  15. # ifndef false
  16. # define false 0
  17. # endif
  18. # ifndef true
  19. # define true 1
  20. # endif
  21.  
  22. # ifdef yyInline
  23. # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) \
  24.   if ((ptr = (tree) free) >= (tree) max) ptr = alloc (); \
  25.   free += nodesize [kind]; \
  26.   ptr->yyHead.yyMark = 0; \
  27.   ptr->Kind = kind;
  28. # else
  29. # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) ptr = make (kind);
  30. # endif
  31.  
  32. # define yyWrite(s) (void) fputs (s, yyf)
  33. # define yyWriteNl (void) fputc ('\n', yyf)
  34.  
  35. # line 65 "AdaptAnalysis.puma"
  36.  
  37.  
  38. # include "Idents.h"
  39. # include "StringMe.h"
  40.  
  41. # include "protocol.h"
  42.  
  43. # include "ShowDefs.h"
  44. # include "Types.h"
  45.  
  46. # include "Globals.h"  /* AdaptAnalSend/GetParams */
  47.  
  48. # include "Shapes.h"        /* make normal shapes */
  49. # include "IndexSha.h"
  50.  
  51. static int distributed_arrays;
  52. static int host_arrays;
  53.  
  54.        /*************************************************
  55.        *                                                *
  56.        *  error_analysis (string, tree)                 *
  57.        *                                                *
  58.        *   - aborts for serious, internal errors        *
  59.        *                                                *
  60.        *************************************************/
  61.  
  62. void error_analysis (s, t)
  63. char s[];
  64. tTree t;
  65.  
  66. { error_protocol (s);
  67.   printf ("Error in AdaptAnalysis : %s\n", s);
  68.   WriteTree (stdout, t);
  69.   kill_in_protocol ();
  70. }
  71.  
  72.  
  73.  
  74. static FILE * yyf = stdout;
  75.  
  76. static void yyAbort
  77. # ifdef __cplusplus
  78.  (char * yyFunction)
  79. # else
  80.  (yyFunction) char * yyFunction;
  81. # endif
  82. {
  83.  (void) fprintf (stderr, "Error: module AdaptAnalysis, routine %s failed\n", yyFunction);
  84.  exit (1);
  85. }
  86.  
  87. void AdaptAnalysis ARGS((tTree t));
  88. static void DeclAnalysis ARGS((tTree t));
  89. static void CheckReplicatedVars ARGS((tTree t, tTree decl));
  90. static void CheckNameListVars ARGS((tTree t, tTree nl));
  91. static void ACFAnalysis ARGS((tTree t));
  92. static void AnalExpression ARGS((tTree t));
  93. static void AdaptAnalForall ARGS((tTree t, int conditions));
  94. static void AnalWhereBody ARGS((tTree t));
  95. static void AdaptAnalDistributions ARGS((tDefinitions t));
  96. static void CheckObjKind ARGS((tDefinitions obj));
  97. static void SetDistributionId ARGS((tDefinitions d, tDefinitions Obj));
  98. static int CountDistributedDims ARGS((tDefinitions dist));
  99. static void AdaptIOAnalysis ARGS((tTree t));
  100. static void AdaptAnalCall ARGS((tTree t, tDefinitions p));
  101. static void AdaptAnalCallParams ARGS((tTree a, tTree f, tDefinitions d));
  102. static void AdaptAnalMatchParam ARGS((tTree actual, tDefinitions formal));
  103. static void MatchDistributions ARGS((tTree actual, tDefinitions formal));
  104. static void AnalIntrinsicFunction ARGS((tIdent name, tTree params));
  105. static void AnalReductionParameters ARGS((tTree params));
  106. static void AnalIntrinsicSubroutine ARGS((tIdent name, tTree params));
  107. static void AdaptAnalReduceParams ARGS((tTree t));
  108. static void AdaptAnalTimerParams ARGS((tTree t));
  109. static void AdaptAnalRandomParams ARGS((tTree t));
  110. static void AdaptAnalGlobalGetParams ARGS((tTree parameter_list));
  111. static void AdaptAnalGlobalSendParams ARGS((tTree parameter_list));
  112. static bool DistributedParameters ARGS((tTree plist));
  113. static bool ReplicatedParameters ARGS((tTree plist));
  114. static void CheckAlignedIndexes ARGS((tTree a, tTree indexlist, int n));
  115. static void CheckAlignedMask ARGS((tTree a, tTree mask));
  116. static void CheckCommons ARGS((tDefinitions t));
  117.  
  118. void AdaptAnalysis
  119. # if defined __STDC__ | defined __cplusplus
  120. (register tTree t)
  121. # else
  122. (t)
  123.  register tTree t;
  124. # endif
  125. {
  126.   if (t == NoTree) return;
  127.  
  128.   switch (t->Kind) {
  129.   case kCOMP_UNIT:
  130. # line 111 "AdaptAnalysis.puma"
  131.   {
  132. # line 112 "AdaptAnalysis.puma"
  133.    open_protocol ("adaptor.anl");
  134. # line 113 "AdaptAnalysis.puma"
  135.    AdaptAnalysis (t->COMP_UNIT.COMP_ELEMENTS);
  136. # line 114 "AdaptAnalysis.puma"
  137.    CheckCommons (GetCommonEntries ());
  138. # line 115 "AdaptAnalysis.puma"
  139.    close_protocol ();
  140.   }
  141.    return;
  142.  
  143.   case kDECL_EMPTY:
  144. # line 120 "AdaptAnalysis.puma"
  145.    return;
  146.  
  147.   case kDECL_LIST:
  148. # line 123 "AdaptAnalysis.puma"
  149.   {
  150. # line 124 "AdaptAnalysis.puma"
  151.    AdaptAnalysis (t->DECL_LIST.Elem);
  152. # line 125 "AdaptAnalysis.puma"
  153.    AdaptAnalysis (t->DECL_LIST.Next);
  154.   }
  155.    return;
  156.  
  157.   case kPROGRAM_DECL:
  158. # line 137 "AdaptAnalysis.puma"
  159.  {
  160.   tDefinitions Obj;
  161.   {
  162. # line 138 "AdaptAnalysis.puma"
  163.    set_protocol_unit (t);
  164. # line 139 "AdaptAnalysis.puma"
  165.  
  166. # line 140 "AdaptAnalysis.puma"
  167.    Obj = GetDeclEntry (t->PROGRAM_DECL.Name, GetUnitEntries ());
  168. # line 141 "AdaptAnalysis.puma"
  169.    OpenScope (Obj->ProcObject.Declarations);
  170. # line 142 "AdaptAnalysis.puma"
  171.    AdaptAnalysis (t->PROGRAM_DECL.PROGRAM_BODY);
  172. # line 143 "AdaptAnalysis.puma"
  173.    CloseScope ();
  174.   }
  175.    return;
  176.  }
  177.  
  178.   case kPROC_DECL:
  179. # line 146 "AdaptAnalysis.puma"
  180.  {
  181.   tDefinitions Obj;
  182.   {
  183. # line 147 "AdaptAnalysis.puma"
  184.    set_protocol_unit (t);
  185. # line 148 "AdaptAnalysis.puma"
  186.  
  187. # line 149 "AdaptAnalysis.puma"
  188.    Obj = GetDeclEntry (t->PROC_DECL.Name, GetUnitEntries ());
  189. # line 150 "AdaptAnalysis.puma"
  190.    OpenScope (Obj->ProcObject.Declarations);
  191. # line 151 "AdaptAnalysis.puma"
  192.    DeclAnalysis (t->PROC_DECL.FORMALS);
  193. # line 152 "AdaptAnalysis.puma"
  194.    AdaptAnalysis (t->PROC_DECL.PROC_BODY);
  195. # line 153 "AdaptAnalysis.puma"
  196.    CloseScope ();
  197.   }
  198.    return;
  199.  }
  200.  
  201.   case kFUNC_DECL:
  202. # line 156 "AdaptAnalysis.puma"
  203.  {
  204.   tDefinitions Obj;
  205.   {
  206. # line 157 "AdaptAnalysis.puma"
  207.    set_protocol_unit (t);
  208. # line 158 "AdaptAnalysis.puma"
  209.  
  210. # line 159 "AdaptAnalysis.puma"
  211.    Obj = GetDeclEntry (t->FUNC_DECL.Name, GetUnitEntries ());
  212. # line 160 "AdaptAnalysis.puma"
  213.    OpenScope (Obj->FuncObject.Declarations);
  214. # line 161 "AdaptAnalysis.puma"
  215.    DeclAnalysis (t->FUNC_DECL.FORMALS);
  216. # line 162 "AdaptAnalysis.puma"
  217.    AdaptAnalysis (t->FUNC_DECL.FUNC_BODY);
  218. # line 163 "AdaptAnalysis.puma"
  219.  if (host_arrays > 0)
  220.         simple_error_protocol ("FUNCTION has host arrays");
  221.       if (distributed_arrays > 0)
  222.         simple_error_protocol ("FUNCTION has distrubted arrays");
  223.  
  224. # line 168 "AdaptAnalysis.puma"
  225.    CloseScope ();
  226.   }
  227.    return;
  228.  }
  229.  
  230.   case kMODULE_DECL:
  231. # line 171 "AdaptAnalysis.puma"
  232.   {
  233. # line 172 "AdaptAnalysis.puma"
  234.    tree_error_protocol ("MODULE not supported", t);
  235.   }
  236.    return;
  237.  
  238.   case kBLOCK_DATA_DECL:
  239. # line 175 "AdaptAnalysis.puma"
  240.  {
  241.   tDefinitions Obj;
  242.   {
  243. # line 176 "AdaptAnalysis.puma"
  244.    set_protocol_unit (t);
  245. # line 177 "AdaptAnalysis.puma"
  246.  
  247. # line 178 "AdaptAnalysis.puma"
  248.    Obj = GetDeclEntry (t->BLOCK_DATA_DECL.Name, GetUnitEntries ());
  249. # line 179 "AdaptAnalysis.puma"
  250.    OpenScope (Obj->BlockObject.Declarations);
  251. # line 180 "AdaptAnalysis.puma"
  252.    AdaptAnalysis (t->BLOCK_DATA_DECL.DATA_BODY);
  253. # line 181 "AdaptAnalysis.puma"
  254.    CloseScope ();
  255.   }
  256.    return;
  257.  }
  258.  
  259.   case kBODY_NODE:
  260.   if (t->BODY_NODE.INTERNALS->Kind == kDECL_EMPTY) {
  261. # line 194 "AdaptAnalysis.puma"
  262.   {
  263. # line 196 "AdaptAnalysis.puma"
  264.    host_arrays = 0;
  265. # line 197 "AdaptAnalysis.puma"
  266.    distributed_arrays = 0;
  267. # line 199 "AdaptAnalysis.puma"
  268.    DeclAnalysis (t->BODY_NODE.DECLS);
  269. # line 201 "AdaptAnalysis.puma"
  270.    AdaptAnalDistributions (GetCurrentScope ());
  271. # line 204 "AdaptAnalysis.puma"
  272.    ACFAnalysis (t->BODY_NODE.STATS);
  273. # line 206 "AdaptAnalysis.puma"
  274.  if ((target_model != HOST_NODE) && (host_arrays > 0))
  275.         simple_error_protocol
  276.            ("Model ONLY_NODE/UNIPROC: no host arrays are allowed");
  277.  
  278.   }
  279.    return;
  280.  
  281.   }
  282. # line 212 "AdaptAnalysis.puma"
  283.   {
  284. # line 213 "AdaptAnalysis.puma"
  285.    tree_error_protocol ("internal subroutines/functions are not supported", t);
  286.   }
  287.    return;
  288.  
  289.   }
  290.  
  291. # line 216 "AdaptAnalysis.puma"
  292.   {
  293. # line 217 "AdaptAnalysis.puma"
  294.    error_analysis ("unknown tree node AdaptAnalysis", t);
  295.   }
  296.    return;
  297.  
  298. ;
  299. }
  300.  
  301. static void DeclAnalysis
  302. # if defined __STDC__ | defined __cplusplus
  303. (register tTree t)
  304. # else
  305. (t)
  306.  register tTree t;
  307. # endif
  308. {
  309.   if (t == NoTree) return;
  310.  
  311.   switch (t->Kind) {
  312.   case kDECL_EMPTY:
  313. # line 228 "AdaptAnalysis.puma"
  314.    return;
  315.  
  316.   case kDECL_LIST:
  317. # line 231 "AdaptAnalysis.puma"
  318.   {
  319. # line 232 "AdaptAnalysis.puma"
  320.    DeclAnalysis (t->DECL_LIST.Elem);
  321. # line 233 "AdaptAnalysis.puma"
  322.    DeclAnalysis (t->DECL_LIST.Next);
  323.   }
  324.    return;
  325.  
  326.   case kVAR_DECL:
  327. # line 236 "AdaptAnalysis.puma"
  328.    return;
  329.  
  330.   case kTEMPLATE_DECL:
  331. # line 239 "AdaptAnalysis.puma"
  332.    return;
  333.  
  334.   case kPARAMETER_DECL:
  335. # line 242 "AdaptAnalysis.puma"
  336.    return;
  337.  
  338.   case kEXTERNAL_DECL:
  339. # line 245 "AdaptAnalysis.puma"
  340.    return;
  341.  
  342.   case kINTRINSIC_DECL:
  343. # line 248 "AdaptAnalysis.puma"
  344.    return;
  345.  
  346.   case kDIMENSION_DECL:
  347. # line 251 "AdaptAnalysis.puma"
  348.    return;
  349.  
  350.   case kSAVE_DECL:
  351. # line 254 "AdaptAnalysis.puma"
  352.    return;
  353.  
  354.   case kSEQUENCE_DECL:
  355. # line 257 "AdaptAnalysis.puma"
  356.    return;
  357.  
  358.   case kNOSEQUENCE_DECL:
  359. # line 260 "AdaptAnalysis.puma"
  360.    return;
  361.  
  362.   case kINIT_DATA_DECL:
  363. # line 263 "AdaptAnalysis.puma"
  364.   {
  365. # line 264 "AdaptAnalysis.puma"
  366.    tree_error_protocol ("make initial values to initial statements", t);
  367.   }
  368.    return;
  369.  
  370.   case kALLOCATABLE_DECL:
  371. # line 267 "AdaptAnalysis.puma"
  372.   {
  373. # line 268 "AdaptAnalysis.puma"
  374.    tree_error_protocol ("use of this attribute unnecessary", t);
  375.   }
  376.    return;
  377.  
  378.   case kOPTIONAL_DECL:
  379. # line 271 "AdaptAnalysis.puma"
  380.   {
  381. # line 272 "AdaptAnalysis.puma"
  382.    tree_error_protocol ("optional arguments not supported", t);
  383.   }
  384.    return;
  385.  
  386.   case kINTENT_DECL:
  387. # line 275 "AdaptAnalysis.puma"
  388.    return;
  389.  
  390.   case kTARGET_DECL:
  391. # line 279 "AdaptAnalysis.puma"
  392.   {
  393. # line 280 "AdaptAnalysis.puma"
  394.    tree_error_protocol ("target attribute is not supported", t);
  395.   }
  396.    return;
  397.  
  398.   case kPOINTER_DECL:
  399. # line 283 "AdaptAnalysis.puma"
  400.   {
  401. # line 284 "AdaptAnalysis.puma"
  402.    tree_error_protocol ("pointer attribute is not supported", t);
  403.   }
  404.    return;
  405.  
  406.   case kPUBLIC_DECL:
  407. # line 287 "AdaptAnalysis.puma"
  408.   {
  409. # line 288 "AdaptAnalysis.puma"
  410.    tree_error_protocol ("public attribute is not supported", t);
  411.   }
  412.    return;
  413.  
  414.   case kPRIVATE_DECL:
  415. # line 291 "AdaptAnalysis.puma"
  416.   {
  417. # line 292 "AdaptAnalysis.puma"
  418.    tree_error_protocol ("private attribute is not supported", t);
  419.   }
  420.    return;
  421.  
  422.   case kALIGN_DECL:
  423. # line 295 "AdaptAnalysis.puma"
  424.    return;
  425.  
  426.   case kDISTRIBUTE_DECL:
  427. # line 299 "AdaptAnalysis.puma"
  428.    return;
  429.  
  430.   case kNAMELIST_DECL:
  431. # line 303 "AdaptAnalysis.puma"
  432.   {
  433. # line 305 "AdaptAnalysis.puma"
  434.    CheckNameListVars (t->NAMELIST_DECL.IDS, t);
  435.   }
  436.    return;
  437.  
  438.   case kCOMMON_DECL:
  439. # line 308 "AdaptAnalysis.puma"
  440.    return;
  441.  
  442.   case kEQV_DECL:
  443. # line 313 "AdaptAnalysis.puma"
  444.   {
  445. # line 314 "AdaptAnalysis.puma"
  446.    CheckReplicatedVars (t->EQV_DECL.VARS, t);
  447.   }
  448.    return;
  449.  
  450.   case kDATA_DECL:
  451. # line 317 "AdaptAnalysis.puma"
  452.   {
  453. # line 318 "AdaptAnalysis.puma"
  454.    CheckReplicatedVars (t->DATA_DECL.VARS, t);
  455.   }
  456.    return;
  457.  
  458.   case kIMPLICIT_DECL:
  459. # line 321 "AdaptAnalysis.puma"
  460.    return;
  461.  
  462.   case kVAR_PARAM_DECL:
  463. # line 325 "AdaptAnalysis.puma"
  464.    return;
  465.  
  466.   case kSTMT_FUNC_DECL:
  467. # line 328 "AdaptAnalysis.puma"
  468.    return;
  469.  
  470.   case kINTERFACE_DECL:
  471. # line 332 "AdaptAnalysis.puma"
  472.    return;
  473.  
  474.   }
  475.  
  476. # line 336 "AdaptAnalysis.puma"
  477.   {
  478. # line 337 "AdaptAnalysis.puma"
  479.    error_analysis ("unknown tree node DeclAnalysis", t);
  480.   }
  481.    return;
  482.  
  483. ;
  484. }
  485.  
  486. static void CheckReplicatedVars
  487. # if defined __STDC__ | defined __cplusplus
  488. (register tTree t, register tTree decl)
  489. # else
  490. (t, decl)
  491.  register tTree t;
  492.  register tTree decl;
  493. # endif
  494. {
  495.   if (t == NoTree) return;
  496.   if (decl == NoTree) return;
  497.   if (t->Kind == kBTV_LIST) {
  498. # line 350 "AdaptAnalysis.puma"
  499.   {
  500. # line 351 "AdaptAnalysis.puma"
  501.    CheckReplicatedVars (t->BTV_LIST.Elem, decl);
  502. # line 352 "AdaptAnalysis.puma"
  503.    CheckReplicatedVars (t->BTV_LIST.Next, decl);
  504.   }
  505.    return;
  506.  
  507.   }
  508.   if (t->Kind == kBTV_EMPTY) {
  509. # line 355 "AdaptAnalysis.puma"
  510.    return;
  511.  
  512.   }
  513.   if (t->Kind == kUSED_VAR) {
  514. # line 358 "AdaptAnalysis.puma"
  515.   {
  516. # line 359 "AdaptAnalysis.puma"
  517.    CheckReplicatedVars (t->USED_VAR.VARNAME, decl);
  518.   }
  519.    return;
  520.  
  521.   }
  522.   if (t->Kind == kINDEXED_VAR) {
  523.   if (t->INDEXED_VAR.IND_VAR->Kind == kUSED_VAR) {
  524. # line 362 "AdaptAnalysis.puma"
  525.   {
  526. # line 363 "AdaptAnalysis.puma"
  527.    CheckReplicatedVars (t->INDEXED_VAR.IND_VAR->USED_VAR.VARNAME, decl);
  528.   }
  529.    return;
  530.  
  531.   }
  532.   }
  533.   if (t->Kind == kVAR_OBJ) {
  534. # line 366 "AdaptAnalysis.puma"
  535.   {
  536. # line 367 "AdaptAnalysis.puma"
  537.    if (! ((TreeDistribution (t) != 0))) goto yyL5;
  538.   {
  539. # line 368 "AdaptAnalysis.puma"
  540.    simple_error_protocol ("only replicated variables in DATA, EQUIVALENCE");
  541. # line 369 "AdaptAnalysis.puma"
  542.    tree_protocol ("Illegal declaration is : \n", decl);
  543. # line 370 "AdaptAnalysis.puma"
  544.    tree_protocol ("Illegal variable is : ", t);
  545.   }
  546.   }
  547.    return;
  548. yyL5:;
  549.  
  550. # line 373 "AdaptAnalysis.puma"
  551.    return;
  552.  
  553.   }
  554.   if (t->Kind == kDO_VAR) {
  555. # line 376 "AdaptAnalysis.puma"
  556.   {
  557. # line 377 "AdaptAnalysis.puma"
  558.    CheckReplicatedVars (t->DO_VAR.BODY, decl);
  559.   }
  560.    return;
  561.  
  562.   }
  563. # line 380 "AdaptAnalysis.puma"
  564.   {
  565. # line 381 "AdaptAnalysis.puma"
  566.    error_analysis ("unknown tree node CheckReplicatedVars", t);
  567.   }
  568.    return;
  569.  
  570. ;
  571. }
  572.  
  573. static void CheckNameListVars
  574. # if defined __STDC__ | defined __cplusplus
  575. (register tTree t, register tTree nl)
  576. # else
  577. (t, nl)
  578.  register tTree t;
  579.  register tTree nl;
  580. # endif
  581. {
  582.   if (t == NoTree) return;
  583.   if (nl == NoTree) return;
  584.   if (t->Kind == kDECL_LIST) {
  585. # line 394 "AdaptAnalysis.puma"
  586.   {
  587. # line 395 "AdaptAnalysis.puma"
  588.    CheckNameListVars (t->DECL_LIST.Elem, nl);
  589. # line 396 "AdaptAnalysis.puma"
  590.    CheckNameListVars (t->DECL_LIST.Next, nl);
  591.   }
  592.    return;
  593.  
  594.   }
  595.   if (t->Kind == kVAR_DECL) {
  596. # line 399 "AdaptAnalysis.puma"
  597.  {
  598.   tDefinitions Obj;
  599.   {
  600. # line 400 "AdaptAnalysis.puma"
  601.  
  602. # line 401 "AdaptAnalysis.puma"
  603.    Obj = GetLocalDecl (t->VAR_DECL.Name);
  604. # line 402 "AdaptAnalysis.puma"
  605.  if (VarDistribution (Obj) == 1)
  606.          { error_protocol ("Distributed variable in NAMELIST");
  607.            tree_protocol  ("namelist        : ", nl);
  608.            tree_protocol  ("distributed var : ", t);
  609.          }
  610.  
  611.   }
  612.    return;
  613.  }
  614.  
  615.   }
  616. ;
  617. }
  618.  
  619. static void ACFAnalysis
  620. # if defined __STDC__ | defined __cplusplus
  621. (register tTree t)
  622. # else
  623. (t)
  624.  register tTree t;
  625. # endif
  626. {
  627.   if (t == NoTree) return;
  628.  
  629.   switch (t->Kind) {
  630.   case kACF_LIST:
  631. # line 418 "AdaptAnalysis.puma"
  632.   {
  633. # line 419 "AdaptAnalysis.puma"
  634.    set_protocol_stmt (t->ACF_LIST.Elem);
  635. # line 420 "AdaptAnalysis.puma"
  636.    ACFAnalysis (t->ACF_LIST.Elem);
  637. # line 421 "AdaptAnalysis.puma"
  638.    ACFAnalysis (t->ACF_LIST.Next);
  639.   }
  640.    return;
  641.  
  642.   case kACF_EMPTY:
  643. # line 424 "AdaptAnalysis.puma"
  644.    return;
  645.  
  646.   case kACF_DUMMY:
  647. # line 427 "AdaptAnalysis.puma"
  648.    return;
  649.  
  650.   case kACF_BASIC:
  651. # line 430 "AdaptAnalysis.puma"
  652.   {
  653. # line 431 "AdaptAnalysis.puma"
  654.    ACFAnalysis (t->ACF_BASIC.BASIC_STMT);
  655.   }
  656.    return;
  657.  
  658.   case kACF_IF:
  659. # line 434 "AdaptAnalysis.puma"
  660.   {
  661. # line 435 "AdaptAnalysis.puma"
  662.  t->ACF_IF.IF_EXP = NormalArrayIndexes (t->ACF_IF.IF_EXP);
  663. # line 436 "AdaptAnalysis.puma"
  664.    AnalExpression (t->ACF_IF.IF_EXP);
  665. # line 437 "AdaptAnalysis.puma"
  666.    ACFAnalysis (t->ACF_IF.THEN_PART);
  667. # line 438 "AdaptAnalysis.puma"
  668.    ACFAnalysis (t->ACF_IF.ELSE_PART);
  669.   }
  670.    return;
  671.  
  672.   case kACF_WHERE:
  673. # line 441 "AdaptAnalysis.puma"
  674.   {
  675. # line 442 "AdaptAnalysis.puma"
  676.  t->ACF_WHERE.WHERE_EXP = NormalArrayIndexes (t->ACF_WHERE.WHERE_EXP);
  677. # line 443 "AdaptAnalysis.puma"
  678.    AnalExpression (t->ACF_WHERE.WHERE_EXP);
  679. # line 444 "AdaptAnalysis.puma"
  680.    AnalWhereBody (t->ACF_WHERE.TRUE_PART);
  681. # line 445 "AdaptAnalysis.puma"
  682.    AnalWhereBody (t->ACF_WHERE.FALSE_PART);
  683.   }
  684.    return;
  685.  
  686.   case kACF_CASE:
  687. # line 448 "AdaptAnalysis.puma"
  688.   {
  689. # line 449 "AdaptAnalysis.puma"
  690.  t->ACF_CASE.CASE_EXP = NormalArrayIndexes (t->ACF_CASE.CASE_EXP);
  691. # line 450 "AdaptAnalysis.puma"
  692.    AnalExpression (t->ACF_CASE.CASE_EXP);
  693. # line 451 "AdaptAnalysis.puma"
  694.    ACFAnalysis (t->ACF_CASE.CASE_ALTS);
  695. # line 452 "AdaptAnalysis.puma"
  696.    ACFAnalysis (t->ACF_CASE.CASE_OTHERWISE);
  697.   }
  698.    return;
  699.  
  700.   case kACF_WHILE:
  701. # line 455 "AdaptAnalysis.puma"
  702.   {
  703. # line 456 "AdaptAnalysis.puma"
  704.  t->ACF_WHILE.WHILE_EXP = NormalArrayIndexes (t->ACF_WHILE.WHILE_EXP);
  705. # line 457 "AdaptAnalysis.puma"
  706.    AnalExpression (t->ACF_WHILE.WHILE_EXP);
  707. # line 458 "AdaptAnalysis.puma"
  708.    ACFAnalysis (t->ACF_WHILE.WHILE_BODY);
  709.   }
  710.    return;
  711.  
  712.   case kACF_DOALL:
  713. # line 461 "AdaptAnalysis.puma"
  714.   {
  715. # line 462 "AdaptAnalysis.puma"
  716.  t->ACF_DOALL.DOALL_ID = NormalArrayIndexes (t->ACF_DOALL.DOALL_ID);
  717. # line 463 "AdaptAnalysis.puma"
  718.  t->ACF_DOALL.DOALL_RANGE = NormalArrayIndexes (t->ACF_DOALL.DOALL_RANGE);
  719. # line 464 "AdaptAnalysis.puma"
  720.    AnalExpression (t->ACF_DOALL.DOALL_ID);
  721. # line 465 "AdaptAnalysis.puma"
  722.    AnalExpression (t->ACF_DOALL.DOALL_RANGE);
  723. # line 466 "AdaptAnalysis.puma"
  724.    error_protocol ("only independent with local access is supported");
  725. # line 467 "AdaptAnalysis.puma"
  726.    ACFAnalysis (t->ACF_DOALL.DOALL_BODY);
  727.   }
  728.    return;
  729.  
  730.   case kACF_FORALL:
  731. # line 471 "AdaptAnalysis.puma"
  732.   {
  733. # line 472 "AdaptAnalysis.puma"
  734.  t->ACF_FORALL.FORALL_ID = NormalArrayIndexes (t->ACF_FORALL.FORALL_ID);
  735. # line 473 "AdaptAnalysis.puma"
  736.  t->ACF_FORALL.FORALL_RANGE = NormalArrayIndexes (t->ACF_FORALL.FORALL_RANGE);
  737. # line 474 "AdaptAnalysis.puma"
  738.    AnalExpression (t->ACF_FORALL.FORALL_ID);
  739. # line 475 "AdaptAnalysis.puma"
  740.    AnalExpression (t->ACF_FORALL.FORALL_RANGE);
  741. # line 476 "AdaptAnalysis.puma"
  742.    AdaptAnalForall (t->ACF_FORALL.FORALL_BODY, 0);
  743.   }
  744.    return;
  745.  
  746.   case kACF_DOLOCAL:
  747. # line 479 "AdaptAnalysis.puma"
  748.   {
  749. # line 480 "AdaptAnalysis.puma"
  750.  t->ACF_DOLOCAL.DOLOCAL_ID = NormalArrayIndexes (t->ACF_DOLOCAL.DOLOCAL_ID);
  751. # line 481 "AdaptAnalysis.puma"
  752.  t->ACF_DOLOCAL.DOLOCAL_RANGE = NormalArrayIndexes (t->ACF_DOLOCAL.DOLOCAL_RANGE);
  753. # line 482 "AdaptAnalysis.puma"
  754.    AnalExpression (t->ACF_DOLOCAL.DOLOCAL_ID);
  755. # line 483 "AdaptAnalysis.puma"
  756.    AnalExpression (t->ACF_DOLOCAL.DOLOCAL_RANGE);
  757. # line 484 "AdaptAnalysis.puma"
  758.    ACFAnalysis (t->ACF_DOLOCAL.DOLOCAL_BODY);
  759.   }
  760.    return;
  761.  
  762.   case kACF_DO:
  763. # line 491 "AdaptAnalysis.puma"
  764.   {
  765. # line 492 "AdaptAnalysis.puma"
  766.  t->ACF_DO.DO_ID = NormalArrayIndexes (t->ACF_DO.DO_ID);
  767. # line 493 "AdaptAnalysis.puma"
  768.  t->ACF_DO.DO_RANGE = NormalArrayIndexes (t->ACF_DO.DO_RANGE);
  769. # line 494 "AdaptAnalysis.puma"
  770.    AnalExpression (t->ACF_DO.DO_ID);
  771. # line 495 "AdaptAnalysis.puma"
  772.    AnalExpression (t->ACF_DO.DO_RANGE);
  773. # line 496 "AdaptAnalysis.puma"
  774.    ACFAnalysis (t->ACF_DO.DO_BODY);
  775.   }
  776.    return;
  777.  
  778.   case kASSIGN_STMT:
  779. # line 499 "AdaptAnalysis.puma"
  780.   {
  781. # line 500 "AdaptAnalysis.puma"
  782.  t->ASSIGN_STMT.ASSIGN_VAR = NormalArrayIndexes (t->ASSIGN_STMT.ASSIGN_VAR);
  783.      t->ASSIGN_STMT.ASSIGN_EXP = NormalArrayIndexes (t->ASSIGN_STMT.ASSIGN_EXP);
  784.  
  785. # line 503 "AdaptAnalysis.puma"
  786.    AnalExpression (t->ASSIGN_STMT.ASSIGN_VAR);
  787. # line 504 "AdaptAnalysis.puma"
  788.    AnalExpression (t->ASSIGN_STMT.ASSIGN_EXP);
  789.   }
  790.    return;
  791.  
  792.   case kFORMAT_STMT:
  793. # line 507 "AdaptAnalysis.puma"
  794.    return;
  795.  
  796.   case kIO_STMT:
  797. # line 510 "AdaptAnalysis.puma"
  798.   {
  799. # line 511 "AdaptAnalysis.puma"
  800.    AdaptIOAnalysis (t);
  801.   }
  802.    return;
  803.  
  804.   case kCALL_STMT:
  805. # line 514 "AdaptAnalysis.puma"
  806.   {
  807. # line 516 "AdaptAnalysis.puma"
  808.    if (! (t->CALL_STMT.CALL_ID->PROC_OBJ.Object == GetDeclEntry (t->CALL_STMT.CALL_ID->PROC_OBJ.Ident, GetIntrinsicEntries ()))) goto yyL16;
  809.   {
  810. # line 520 "AdaptAnalysis.puma"
  811.    AnalIntrinsicSubroutine (t->CALL_STMT.CALL_ID->PROC_OBJ.Ident, t->CALL_STMT.CALL_PARAMS);
  812.   }
  813.   }
  814.    return;
  815. yyL16:;
  816.  
  817. # line 523 "AdaptAnalysis.puma"
  818.  {
  819.   int dist;
  820.   {
  821. # line 525 "AdaptAnalysis.puma"
  822.    if (! (t->CALL_STMT.CALL_ID->PROC_OBJ.Object == GetDeclEntry (t->CALL_STMT.CALL_ID->PROC_OBJ.Ident, GetExternalEntries ()))) goto yyL17;
  823.   {
  824. # line 529 "AdaptAnalysis.puma"
  825.  
  826. # line 531 "AdaptAnalysis.puma"
  827.  dist = TreeDistribution (t->CALL_STMT.CALL_PARAMS);
  828.      if ((dist < -1) || (dist > 0) )
  829.       {
  830.         error_protocol ("Node variables in external call");
  831.       }
  832.  
  833.   }
  834.   }
  835.    return;
  836.  }
  837. yyL17:;
  838.  
  839. # line 539 "AdaptAnalysis.puma"
  840.   {
  841. # line 543 "AdaptAnalysis.puma"
  842.    AdaptAnalCall (t, t->CALL_STMT.CALL_ID->PROC_OBJ.Object);
  843.   }
  844.    return;
  845.  
  846.   case kREDUCE_STMT:
  847. # line 546 "AdaptAnalysis.puma"
  848.   {
  849. # line 547 "AdaptAnalysis.puma"
  850.    AdaptAnalReduceParams (t->REDUCE_STMT.RED_PARAMS);
  851.   }
  852.    return;
  853.  
  854.   case kALLOCATE_STMT:
  855. # line 550 "AdaptAnalysis.puma"
  856.   {
  857. # line 552 "AdaptAnalysis.puma"
  858.    SetAllocateShapes (t->ALLOCATE_STMT.PARAMS);
  859.   }
  860.    return;
  861.  
  862.   case kDEALLOCATE_STMT:
  863. # line 555 "AdaptAnalysis.puma"
  864.   {
  865. # line 557 "AdaptAnalysis.puma"
  866.    ResetDeallocateShapes (t->DEALLOCATE_STMT.PARAMS);
  867.   }
  868.    return;
  869.  
  870.   case kNULLIFY_STMT:
  871. # line 560 "AdaptAnalysis.puma"
  872.   {
  873. # line 561 "AdaptAnalysis.puma"
  874.    error_protocol ("nullify not supported within ADAPTOR");
  875.   }
  876.    return;
  877.  
  878.   case kGOTO_STMT:
  879. # line 564 "AdaptAnalysis.puma"
  880.    return;
  881.  
  882.   case kCOMP_GOTO_STMT:
  883. # line 567 "AdaptAnalysis.puma"
  884.   {
  885. # line 568 "AdaptAnalysis.puma"
  886.  t->COMP_GOTO_STMT.GOTO_EXP = NormalArrayIndexes (t->COMP_GOTO_STMT.GOTO_EXP);
  887. # line 569 "AdaptAnalysis.puma"
  888.    AnalExpression (t->COMP_GOTO_STMT.GOTO_EXP);
  889.   }
  890.    return;
  891.  
  892.   case kCOMP_IF_STMT:
  893. # line 572 "AdaptAnalysis.puma"
  894.   {
  895. # line 573 "AdaptAnalysis.puma"
  896.  t->COMP_IF_STMT.IF_EXP = NormalArrayIndexes (t->COMP_IF_STMT.IF_EXP);
  897. # line 574 "AdaptAnalysis.puma"
  898.    AnalExpression (t->COMP_IF_STMT.IF_EXP);
  899.   }
  900.    return;
  901.  
  902.   case kSTOP_STMT:
  903. # line 577 "AdaptAnalysis.puma"
  904.   {
  905. # line 578 "AdaptAnalysis.puma"
  906.  t->STOP_STMT.STOP_CONST = NormalArrayIndexes (t->STOP_STMT.STOP_CONST);
  907.   }
  908.    return;
  909.  
  910.   case kRETURN_STMT:
  911. # line 581 "AdaptAnalysis.puma"
  912.   {
  913. # line 582 "AdaptAnalysis.puma"
  914.  t->RETURN_STMT.RETURN_EXP = NormalArrayIndexes (t->RETURN_STMT.RETURN_EXP);
  915. # line 583 "AdaptAnalysis.puma"
  916.    error_protocol ("Remove RETURN, jump to END of subroutine/function");
  917.   }
  918.    return;
  919.  
  920.   }
  921.  
  922. # line 586 "AdaptAnalysis.puma"
  923.   {
  924. # line 587 "AdaptAnalysis.puma"
  925.    error_analysis ("unknown tree node ACFAnalysis", t);
  926.   }
  927.    return;
  928.  
  929. ;
  930. }
  931.  
  932. static void AnalExpression
  933. # if defined __STDC__ | defined __cplusplus
  934. (register tTree t)
  935. # else
  936. (t)
  937.  register tTree t;
  938. # endif
  939. {
  940.   if (t == NoTree) return;
  941.  
  942.   switch (t->Kind) {
  943.   case kUSED_VAR:
  944. # line 609 "AdaptAnalysis.puma"
  945.   {
  946. # line 610 "AdaptAnalysis.puma"
  947.    AnalExpression (t->USED_VAR.VARNAME);
  948.   }
  949.    return;
  950.  
  951.   case kLOOP_VAR:
  952. # line 613 "AdaptAnalysis.puma"
  953.   {
  954. # line 614 "AdaptAnalysis.puma"
  955.    AnalExpression (t->LOOP_VAR.LOOP_VARNAME);
  956.   }
  957.    return;
  958.  
  959.   case kINDEXED_VAR:
  960. # line 617 "AdaptAnalysis.puma"
  961.   {
  962. # line 618 "AdaptAnalysis.puma"
  963.    AnalExpression (t->INDEXED_VAR.IND_VAR);
  964. # line 619 "AdaptAnalysis.puma"
  965.    AnalExpression (t->INDEXED_VAR.IND_EXPS);
  966.   }
  967.    return;
  968.  
  969.   case kSUBSTRING_VAR:
  970. # line 622 "AdaptAnalysis.puma"
  971.   {
  972. # line 623 "AdaptAnalysis.puma"
  973.    AnalExpression (t->SUBSTRING_VAR.IND_VAR);
  974. # line 624 "AdaptAnalysis.puma"
  975.    AnalExpression (t->SUBSTRING_VAR.IND_EXP);
  976.   }
  977.    return;
  978.  
  979.   case kVAR_OBJ:
  980. # line 627 "AdaptAnalysis.puma"
  981.    return;
  982.  
  983.   case kDUMMY_EXP:
  984. # line 637 "AdaptAnalysis.puma"
  985.    return;
  986.  
  987.   case kCONST_EXP:
  988. # line 640 "AdaptAnalysis.puma"
  989.    return;
  990.  
  991.   case kARRAY_EXP:
  992. # line 643 "AdaptAnalysis.puma"
  993.   {
  994. # line 644 "AdaptAnalysis.puma"
  995.    AnalExpression (t->ARRAY_EXP.ELEMENTS);
  996.   }
  997.    return;
  998.  
  999.   case kSLICE_EXP:
  1000. # line 647 "AdaptAnalysis.puma"
  1001.   {
  1002. # line 648 "AdaptAnalysis.puma"
  1003.    AnalExpression (t->SLICE_EXP.START);
  1004. # line 649 "AdaptAnalysis.puma"
  1005.    AnalExpression (t->SLICE_EXP.STOP);
  1006. # line 650 "AdaptAnalysis.puma"
  1007.    AnalExpression (t->SLICE_EXP.INC);
  1008.   }
  1009.    return;
  1010.  
  1011.   case kOP_EXP:
  1012. # line 653 "AdaptAnalysis.puma"
  1013.   {
  1014. # line 654 "AdaptAnalysis.puma"
  1015.    AnalExpression (t->OP_EXP.OPND1);
  1016. # line 655 "AdaptAnalysis.puma"
  1017.    AnalExpression (t->OP_EXP.OPND2);
  1018.   }
  1019.    return;
  1020.  
  1021.   case kOP1_EXP:
  1022. # line 658 "AdaptAnalysis.puma"
  1023.   {
  1024. # line 659 "AdaptAnalysis.puma"
  1025.    AnalExpression (t->OP1_EXP.OPND);
  1026.   }
  1027.    return;
  1028.  
  1029.   case kVAR_EXP:
  1030. # line 662 "AdaptAnalysis.puma"
  1031.   {
  1032. # line 663 "AdaptAnalysis.puma"
  1033.    AnalExpression (t->VAR_EXP.V);
  1034.   }
  1035.    return;
  1036.  
  1037.   case kFUNC_CALL_EXP:
  1038. # line 672 "AdaptAnalysis.puma"
  1039.   {
  1040. # line 674 "AdaptAnalysis.puma"
  1041.    if (! (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Object == GetDeclEntry (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Ident, GetIntrinsicEntries ()))) goto yyL13;
  1042.   {
  1043. # line 675 "AdaptAnalysis.puma"
  1044.    AnalExpression (t->FUNC_CALL_EXP.FUNC_PARAMS);
  1045. # line 676 "AdaptAnalysis.puma"
  1046.  if (IntrFuncKind1 (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Ident))
  1047.          {}
  1048.        else if (IntrFuncKind2 (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Ident))
  1049.          {}
  1050.        else if (IntrFuncKindn (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Ident))
  1051.          {}
  1052.        else
  1053.          AnalIntrinsicFunction (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Ident, t->FUNC_CALL_EXP.FUNC_PARAMS);
  1054.  
  1055.   }
  1056.   }
  1057.    return;
  1058. yyL13:;
  1059.  
  1060. # line 687 "AdaptAnalysis.puma"
  1061.   {
  1062. # line 689 "AdaptAnalysis.puma"
  1063.    if (! (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Object == GetDeclEntry (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Ident, GetUnitEntries ()))) goto yyL14;
  1064.   {
  1065. # line 691 "AdaptAnalysis.puma"
  1066.    AnalExpression (t->FUNC_CALL_EXP.FUNC_PARAMS);
  1067.   }
  1068.   }
  1069.    return;
  1070. yyL14:;
  1071.  
  1072. # line 694 "AdaptAnalysis.puma"
  1073.   {
  1074. # line 696 "AdaptAnalysis.puma"
  1075.    if (! (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Object == GetDeclEntry (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Ident, GetExternalEntries ()))) goto yyL15;
  1076.   {
  1077. # line 698 "AdaptAnalysis.puma"
  1078.    AnalExpression (t->FUNC_CALL_EXP.FUNC_PARAMS);
  1079. # line 699 "AdaptAnalysis.puma"
  1080.  if (target_model != UNI_PROC)
  1081.         error_protocol ("external function call will not adapted");
  1082.  
  1083.   }
  1084.   }
  1085.    return;
  1086. yyL15:;
  1087.  
  1088. # line 704 "AdaptAnalysis.puma"
  1089.   {
  1090. # line 706 "AdaptAnalysis.puma"
  1091.    if (! (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Object == GetLocalDecl (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Ident))) goto yyL16;
  1092.   {
  1093. # line 707 "AdaptAnalysis.puma"
  1094.    if (! (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Object->FuncObject.decl->Kind == kSTMT_FUNC_DECL)) goto yyL16;
  1095.   {
  1096. # line 709 "AdaptAnalysis.puma"
  1097.    AnalExpression (t->FUNC_CALL_EXP.FUNC_PARAMS);
  1098.   }
  1099.   }
  1100.   }
  1101.    return;
  1102. yyL16:;
  1103.  
  1104. # line 712 "AdaptAnalysis.puma"
  1105.   {
  1106. # line 714 "AdaptAnalysis.puma"
  1107.    if (! (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Object == GetLocalDecl (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Ident))) goto yyL17;
  1108.   {
  1109. # line 716 "AdaptAnalysis.puma"
  1110.    AnalExpression (t->FUNC_CALL_EXP.FUNC_PARAMS);
  1111. # line 717 "AdaptAnalysis.puma"
  1112.    error_protocol ("this function call will not adapted");
  1113.   }
  1114.   }
  1115.    return;
  1116. yyL17:;
  1117.  
  1118.   break;
  1119.   case kBTE_LIST:
  1120. # line 726 "AdaptAnalysis.puma"
  1121.   {
  1122. # line 727 "AdaptAnalysis.puma"
  1123.    AnalExpression (t->BTE_LIST.Elem);
  1124. # line 728 "AdaptAnalysis.puma"
  1125.    AnalExpression (t->BTE_LIST.Next);
  1126.   }
  1127.    return;
  1128.  
  1129.   case kBTE_EMPTY:
  1130. # line 731 "AdaptAnalysis.puma"
  1131.    return;
  1132.  
  1133.   case kBTP_LIST:
  1134. # line 740 "AdaptAnalysis.puma"
  1135.   {
  1136. # line 741 "AdaptAnalysis.puma"
  1137.    AnalExpression (t->BTP_LIST.Elem);
  1138. # line 742 "AdaptAnalysis.puma"
  1139.    AnalExpression (t->BTP_LIST.Next);
  1140.   }
  1141.    return;
  1142.  
  1143.   case kBTP_EMPTY:
  1144. # line 745 "AdaptAnalysis.puma"
  1145.    return;
  1146.  
  1147.   case kVAR_PARAM:
  1148. # line 754 "AdaptAnalysis.puma"
  1149.   {
  1150. # line 755 "AdaptAnalysis.puma"
  1151.    AnalExpression (t->VAR_PARAM.V);
  1152.   }
  1153.    return;
  1154.  
  1155.   case kADDR:
  1156. # line 758 "AdaptAnalysis.puma"
  1157.   {
  1158. # line 759 "AdaptAnalysis.puma"
  1159.    AnalExpression (t->ADDR.E);
  1160.   }
  1161.    return;
  1162.  
  1163.   }
  1164.  
  1165. # line 762 "AdaptAnalysis.puma"
  1166.   {
  1167. # line 763 "AdaptAnalysis.puma"
  1168.    error_analysis ("unknown tree in AnalExpression", t);
  1169.   }
  1170.    return;
  1171.  
  1172. ;
  1173. }
  1174.  
  1175. static void AdaptAnalForall
  1176. # if defined __STDC__ | defined __cplusplus
  1177. (register tTree t, register int conditions)
  1178. # else
  1179. (t, conditions)
  1180.  register tTree t;
  1181.  register int conditions;
  1182. # endif
  1183. {
  1184.   if (t == NoTree) return;
  1185.   if (t->Kind == kACF_LIST) {
  1186.   if (t->ACF_LIST.Next->Kind == kACF_EMPTY) {
  1187. # line 778 "AdaptAnalysis.puma"
  1188.   {
  1189. # line 779 "AdaptAnalysis.puma"
  1190.    set_protocol_stmt (t->ACF_LIST.Elem);
  1191. # line 780 "AdaptAnalysis.puma"
  1192.    AdaptAnalForall (t->ACF_LIST.Elem, conditions);
  1193.   }
  1194.    return;
  1195.  
  1196.   }
  1197. # line 783 "AdaptAnalysis.puma"
  1198.   {
  1199. # line 784 "AdaptAnalysis.puma"
  1200.    error_protocol ("only one statement allowed in FORALL");
  1201. # line 786 "AdaptAnalysis.puma"
  1202.    AdaptAnalForall (t->ACF_LIST.Elem, conditions);
  1203. # line 787 "AdaptAnalysis.puma"
  1204.    AdaptAnalForall (t->ACF_LIST.Next, conditions);
  1205.   }
  1206.    return;
  1207.  
  1208.   }
  1209.   if (t->Kind == kACF_BASIC) {
  1210.   if (t->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
  1211. # line 790 "AdaptAnalysis.puma"
  1212.   {
  1213. # line 791 "AdaptAnalysis.puma"
  1214.  t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR = NormalArrayIndexes (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR);
  1215.      t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP = NormalArrayIndexes (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP);
  1216.  
  1217. # line 795 "AdaptAnalysis.puma"
  1218.    AnalExpression (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR);
  1219. # line 796 "AdaptAnalysis.puma"
  1220.    AnalExpression (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP);
  1221.   }
  1222.    return;
  1223.  
  1224.   }
  1225.   }
  1226.   if (t->Kind == kACF_FORALL) {
  1227. # line 799 "AdaptAnalysis.puma"
  1228.   {
  1229. # line 800 "AdaptAnalysis.puma"
  1230.    AnalExpression (t->ACF_FORALL.FORALL_ID);
  1231. # line 801 "AdaptAnalysis.puma"
  1232.    AnalExpression (t->ACF_FORALL.FORALL_RANGE);
  1233. # line 802 "AdaptAnalysis.puma"
  1234.    AdaptAnalForall (t->ACF_FORALL.FORALL_BODY, conditions);
  1235.   }
  1236.    return;
  1237.  
  1238.   }
  1239.   if (t->Kind == kACF_IF) {
  1240.   if (t->ACF_IF.ELSE_PART->Kind == kACF_EMPTY) {
  1241. # line 805 "AdaptAnalysis.puma"
  1242.   {
  1243. # line 806 "AdaptAnalysis.puma"
  1244.    set_protocol_stmt (t);
  1245. # line 807 "AdaptAnalysis.puma"
  1246.  if (conditions > 0)
  1247.         error_protocol ("only one condition allowed in FORALL");
  1248.  
  1249. # line 810 "AdaptAnalysis.puma"
  1250.    AdaptAnalForall (t->ACF_IF.THEN_PART, conditions + 1);
  1251.   }
  1252.    return;
  1253.  
  1254.   }
  1255. # line 813 "AdaptAnalysis.puma"
  1256.   {
  1257. # line 814 "AdaptAnalysis.puma"
  1258.    error_protocol ("ELSE part in FORALL not allowed for ADAPTOR");
  1259.   }
  1260.    return;
  1261.  
  1262.   }
  1263.   if (t->Kind == kACF_WHERE) {
  1264. # line 817 "AdaptAnalysis.puma"
  1265.   {
  1266. # line 818 "AdaptAnalysis.puma"
  1267.    error_protocol ("WHERE in FORALL not allowed for ADAPTOR");
  1268.   }
  1269.    return;
  1270.  
  1271.   }
  1272. # line 821 "AdaptAnalysis.puma"
  1273.   {
  1274. # line 822 "AdaptAnalysis.puma"
  1275.    error_analysis ("unknown tree in AnalForall", t);
  1276.   }
  1277.    return;
  1278.  
  1279. ;
  1280. }
  1281.  
  1282. static void AnalWhereBody
  1283. # if defined __STDC__ | defined __cplusplus
  1284. (register tTree t)
  1285. # else
  1286. (t)
  1287.  register tTree t;
  1288. # endif
  1289. {
  1290.   if (t == NoTree) return;
  1291.   if (t->Kind == kACF_LIST) {
  1292. # line 836 "AdaptAnalysis.puma"
  1293.   {
  1294. # line 837 "AdaptAnalysis.puma"
  1295.    set_protocol_stmt (t->ACF_LIST.Elem);
  1296. # line 838 "AdaptAnalysis.puma"
  1297.    AnalWhereBody (t->ACF_LIST.Elem);
  1298. # line 839 "AdaptAnalysis.puma"
  1299.    AnalWhereBody (t->ACF_LIST.Next);
  1300.   }
  1301.    return;
  1302.  
  1303.   }
  1304.   if (t->Kind == kACF_EMPTY) {
  1305. # line 842 "AdaptAnalysis.puma"
  1306.    return;
  1307.  
  1308.   }
  1309.   if (t->Kind == kACF_BASIC) {
  1310.   if (t->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
  1311. # line 845 "AdaptAnalysis.puma"
  1312.   {
  1313. # line 846 "AdaptAnalysis.puma"
  1314.  t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR = NormalArrayIndexes (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR);
  1315.      t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP = NormalArrayIndexes (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP);
  1316.  
  1317.   }
  1318.    return;
  1319.  
  1320.   }
  1321.   }
  1322.   if (t->Kind == kACF_WHERE) {
  1323. # line 853 "AdaptAnalysis.puma"
  1324.   {
  1325. # line 854 "AdaptAnalysis.puma"
  1326.    error_protocol ("Nesting of WHERE not allowed until now");
  1327.   }
  1328.    return;
  1329.  
  1330.   }
  1331. # line 857 "AdaptAnalysis.puma"
  1332.   {
  1333. # line 858 "AdaptAnalysis.puma"
  1334.    error_protocol ("Illegal Statement in WHERE");
  1335.   }
  1336.    return;
  1337.  
  1338. ;
  1339. }
  1340.  
  1341. static void AdaptAnalDistributions
  1342. # if defined __STDC__ | defined __cplusplus
  1343. (register tDefinitions t)
  1344. # else
  1345. (t)
  1346.  register tDefinitions t;
  1347. # endif
  1348. {
  1349. # line 871 "AdaptAnalysis.puma"
  1350.  
  1351. int rank;
  1352.  
  1353.   if (t == NoDefinitions) return;
  1354.   if (t->Kind == kENTRY_LIST) {
  1355. # line 875 "AdaptAnalysis.puma"
  1356.   {
  1357. # line 876 "AdaptAnalysis.puma"
  1358.    CheckObjKind (t->ENTRY_LIST.Elem);
  1359. # line 877 "AdaptAnalysis.puma"
  1360.    AdaptAnalDistributions (t->ENTRY_LIST.Elem);
  1361. # line 878 "AdaptAnalysis.puma"
  1362.    AdaptAnalDistributions (t->ENTRY_LIST.Next);
  1363.   }
  1364.    return;
  1365.  
  1366.   }
  1367.   if (t->Kind == kENTRY_EMPTY) {
  1368. # line 881 "AdaptAnalysis.puma"
  1369.    return;
  1370.  
  1371.   }
  1372.   if (t->Kind == kVarObject) {
  1373.   if (t->VarObject.Dist->Kind == kDefaultDistribution) {
  1374. # line 890 "AdaptAnalysis.puma"
  1375.   {
  1376. # line 891 "AdaptAnalysis.puma"
  1377.    obj_error_protocol ("Default Distribution should not happen", t);
  1378.   }
  1379.    return;
  1380.  
  1381.   }
  1382.   if (t->VarObject.Dist->Kind == kAlignDistribution) {
  1383. # line 894 "AdaptAnalysis.puma"
  1384.   {
  1385. # line 895 "AdaptAnalysis.puma"
  1386.    obj_error_protocol ("Align Distribution should not happen", t);
  1387.   }
  1388.    return;
  1389.  
  1390.   }
  1391.   if (t->VarObject.Dist->Kind == kSerialDistribution) {
  1392. # line 898 "AdaptAnalysis.puma"
  1393.    return;
  1394.  
  1395.   }
  1396.   if (t->VarObject.Kind->Kind == kVarCommon) {
  1397.   if (t->VarObject.Dist->Kind == kHostDistribution) {
  1398. # line 902 "AdaptAnalysis.puma"
  1399.   {
  1400. # line 903 "AdaptAnalysis.puma"
  1401.    obj_error_protocol ("Host arrays not allowed in COMMON", t);
  1402.   }
  1403.    return;
  1404.  
  1405.   }
  1406.   }
  1407.   if (t->VarObject.Dist->Kind == kHostDistribution) {
  1408. # line 906 "AdaptAnalysis.puma"
  1409.   {
  1410. # line 907 "AdaptAnalysis.puma"
  1411.    SetDistributionId (t->VarObject.Dist, t);
  1412.   }
  1413.    return;
  1414.  
  1415.   }
  1416.   if (t->VarObject.Dist->Kind == kNodeDistribution) {
  1417. # line 910 "AdaptAnalysis.puma"
  1418.   {
  1419. # line 911 "AdaptAnalysis.puma"
  1420.    SetDistributionId (t->VarObject.Dist, t);
  1421.   }
  1422.    return;
  1423.  
  1424.   }
  1425.   }
  1426.   if (t->Kind == kTemplateObject) {
  1427.   if (t->TemplateObject.Dist->Kind == kNodeDistribution) {
  1428. # line 914 "AdaptAnalysis.puma"
  1429.   {
  1430. # line 915 "AdaptAnalysis.puma"
  1431.  if (CountDistributedDims (t->TemplateObject.Dist) != 1)
  1432.        tree_warning_protocol (
  1433.          "only one dimension of template will be distributed : \n", t->TemplateObject.decl);
  1434.  
  1435.   }
  1436.    return;
  1437.  
  1438.   }
  1439.   }
  1440. ;
  1441. }
  1442.  
  1443. static void CheckObjKind
  1444. # if defined __STDC__ | defined __cplusplus
  1445. (register tDefinitions obj)
  1446. # else
  1447. (obj)
  1448.  register tDefinitions obj;
  1449. # endif
  1450. {
  1451.   if (obj == NoDefinitions) return;
  1452.   if (obj->Kind == kVarObject) {
  1453.   if (obj->VarObject.Kind->Kind == kVarLocal) {
  1454.   if (obj->VarObject.Dist->Kind == kNodeDistribution) {
  1455. # line 929 "AdaptAnalysis.puma"
  1456.   {
  1457. # line 930 "AdaptAnalysis.puma"
  1458.    if (! ((obj->VarObject.Kind->VarLocal.IsSave == true))) goto yyL1;
  1459.   {
  1460. # line 931 "AdaptAnalysis.puma"
  1461.    obj_error_protocol ("distributed node arrays cannot be save", obj);
  1462.   }
  1463.   }
  1464.    return;
  1465. yyL1:;
  1466.  
  1467.   }
  1468. # line 934 "AdaptAnalysis.puma"
  1469.   {
  1470. # line 935 "AdaptAnalysis.puma"
  1471.    if (! (obj->VarObject.Kind->VarLocal.dynamic == 3)) goto yyL2;
  1472.   {
  1473. # line 936 "AdaptAnalysis.puma"
  1474.    obj_error_protocol ("assumed size not allowed for local variables", obj);
  1475.   }
  1476.   }
  1477.    return;
  1478. yyL2:;
  1479.  
  1480.   }
  1481.   if (obj->VarObject.Kind->Kind == kVarDummy) {
  1482. # line 939 "AdaptAnalysis.puma"
  1483.   {
  1484. # line 940 "AdaptAnalysis.puma"
  1485.    if (! (obj->VarObject.Kind->VarDummy.dynamic == 2)) goto yyL3;
  1486.   {
  1487. # line 941 "AdaptAnalysis.puma"
  1488.    obj_error_protocol ("assumed-shaped dummy arrays not supported", obj);
  1489.   }
  1490.   }
  1491.    return;
  1492. yyL3:;
  1493.  
  1494.   if (obj->VarObject.Dist->Kind == kNodeDistribution) {
  1495. # line 944 "AdaptAnalysis.puma"
  1496.   {
  1497. # line 946 "AdaptAnalysis.puma"
  1498.    if (! (obj->VarObject.Kind->VarDummy.dynamic == 3)) goto yyL4;
  1499.   {
  1500. # line 947 "AdaptAnalysis.puma"
  1501.    obj_error_protocol ("assumed size arrays must not be distributed", obj);
  1502.   }
  1503.   }
  1504.    return;
  1505. yyL4:;
  1506.  
  1507.   }
  1508.   }
  1509.   }
  1510. # line 950 "AdaptAnalysis.puma"
  1511.    return;
  1512.  
  1513. ;
  1514. }
  1515.  
  1516. static void SetDistributionId
  1517. # if defined __STDC__ | defined __cplusplus
  1518. (register tDefinitions d, register tDefinitions Obj)
  1519. # else
  1520. (d, Obj)
  1521.  register tDefinitions d;
  1522.  register tDefinitions Obj;
  1523. # endif
  1524. {
  1525. # line 961 "AdaptAnalysis.puma"
  1526.  
  1527. int rank;
  1528. char msg[100];
  1529.  
  1530.   if (d == NoDefinitions) return;
  1531.   if (Obj == NoDefinitions) return;
  1532.   if (d->Kind == kDefaultDistribution) {
  1533. # line 966 "AdaptAnalysis.puma"
  1534.   {
  1535. # line 967 "AdaptAnalysis.puma"
  1536.    obj_error_protocol ("object has still default distribution", Obj);
  1537.   }
  1538.    return;
  1539.  
  1540.   }
  1541.   if (d->Kind == kAlignDistribution) {
  1542. # line 970 "AdaptAnalysis.puma"
  1543.   {
  1544. # line 971 "AdaptAnalysis.puma"
  1545.    obj_error_protocol ("alignment not supported", Obj);
  1546.   }
  1547.    return;
  1548.  
  1549.   }
  1550.   if (d->Kind == kSerialDistribution) {
  1551. # line 974 "AdaptAnalysis.puma"
  1552.    return;
  1553.  
  1554.   }
  1555.   if (d->Kind == kHostDistribution) {
  1556. # line 977 "AdaptAnalysis.puma"
  1557.   {
  1558. # line 978 "AdaptAnalysis.puma"
  1559.  
  1560.      host_arrays += 1;
  1561.      rank   = VarRank(Obj);
  1562.      if (rank > MAX_DIMENSIONS)
  1563.         { sprintf (msg, "host array has rank %d, maximal rank is %d",
  1564.                    rank, MAX_DIMENSIONS);
  1565.           obj_error_protocol (msg, Obj);
  1566.         }
  1567.  
  1568.   }
  1569.    return;
  1570.  
  1571.   }
  1572.   if (d->Kind == kNodeDistribution) {
  1573. # line 989 "AdaptAnalysis.puma"
  1574.   {
  1575. # line 990 "AdaptAnalysis.puma"
  1576.  
  1577.      distributed_arrays += 1;
  1578.      if (CountDistributedDims (d) != 1)
  1579.        tree_warning_protocol
  1580.          ("only one dimension will be distributed : \n", Obj->Object.decl);
  1581.      rank   = VarRank(Obj);
  1582.      if (rank > MAX_DIMENSIONS)
  1583.         { sprintf (msg, "distributed array has rank %d, maximal rank is %d",
  1584.                    rank, MAX_DIMENSIONS);
  1585.           obj_error_protocol (msg, Obj);
  1586.         }
  1587.  
  1588.   }
  1589.    return;
  1590.  
  1591.   }
  1592. # line 1004 "AdaptAnalysis.puma"
  1593.   {
  1594. # line 1005 "AdaptAnalysis.puma"
  1595.    obj_error_protocol ("not supported distribution", Obj);
  1596.   }
  1597.    return;
  1598.  
  1599. ;
  1600. }
  1601.  
  1602. static int CountDistributedDims
  1603. # if defined __STDC__ | defined __cplusplus
  1604. (register tDefinitions dist)
  1605. # else
  1606. (dist)
  1607.  register tDefinitions dist;
  1608. # endif
  1609. {
  1610. # line 1016 "AdaptAnalysis.puma"
  1611.  
  1612. int i, rank, no;
  1613.  
  1614.   if (dist->Kind == kNodeDistribution) {
  1615. # line 1020 "AdaptAnalysis.puma"
  1616.   {
  1617. # line 1021 "AdaptAnalysis.puma"
  1618.  no = 0;
  1619.      rank = dist->NodeDistribution.dims.no_dims;
  1620.      for (i=0; i < rank; i++)
  1621.         if (dist->NodeDistribution.dims.DimsArray[i] > 0) no += 1;
  1622.  
  1623.   }
  1624.    return no;
  1625.  
  1626.   }
  1627.  yyAbort ("CountDistributedDims");
  1628. }
  1629.  
  1630. static void AdaptIOAnalysis
  1631. # if defined __STDC__ | defined __cplusplus
  1632. (register tTree t)
  1633. # else
  1634. (t)
  1635.  register tTree t;
  1636. # endif
  1637. {
  1638. # line 1037 "AdaptAnalysis.puma"
  1639.  
  1640. unsigned char string[256];
  1641. tObject Obj;
  1642. int dist;
  1643.  
  1644.   if (t == NoTree) return;
  1645.   if (t->Kind == kIO_STMT) {
  1646.   if (equaltIdent (t->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("PRINT", 5))) {
  1647. # line 1043 "AdaptAnalysis.puma"
  1648.   {
  1649. # line 1045 "AdaptAnalysis.puma"
  1650.    AdaptIOAnalysis (t->IO_STMT.IO_ITEMS);
  1651.   }
  1652.    return;
  1653.  
  1654.   }
  1655.   if (equaltIdent (t->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("READ", 4))) {
  1656. # line 1048 "AdaptAnalysis.puma"
  1657.   {
  1658. # line 1050 "AdaptAnalysis.puma"
  1659.    AdaptIOAnalysis (t->IO_STMT.IO_ITEMS);
  1660.   }
  1661.    return;
  1662.  
  1663.   }
  1664.   if (equaltIdent (t->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("WRITE", 5))) {
  1665. # line 1053 "AdaptAnalysis.puma"
  1666.   {
  1667. # line 1055 "AdaptAnalysis.puma"
  1668.    AdaptIOAnalysis (t->IO_STMT.IO_ITEMS);
  1669.   }
  1670.    return;
  1671.  
  1672.   }
  1673.   if (equaltIdent (t->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("OPEN", 4))) {
  1674. # line 1058 "AdaptAnalysis.puma"
  1675.    return;
  1676.  
  1677.   }
  1678.   if (equaltIdent (t->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("CLOSE", 5))) {
  1679. # line 1061 "AdaptAnalysis.puma"
  1680.    return;
  1681.  
  1682.   }
  1683.   if (equaltIdent (t->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("REWIND", 6))) {
  1684. # line 1064 "AdaptAnalysis.puma"
  1685.    return;
  1686.  
  1687.   }
  1688.   if (equaltIdent (t->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("BACKSPACE", 9))) {
  1689. # line 1067 "AdaptAnalysis.puma"
  1690.    return;
  1691.  
  1692.   }
  1693.   if (equaltIdent (t->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("INQUIRE", 7))) {
  1694. # line 1070 "AdaptAnalysis.puma"
  1695.    return;
  1696.  
  1697.   }
  1698. # line 1073 "AdaptAnalysis.puma"
  1699.   {
  1700. # line 1074 "AdaptAnalysis.puma"
  1701.    GetString (t->IO_STMT.ID->PROC_OBJ.Ident, string);
  1702. # line 1075 "AdaptAnalysis.puma"
  1703.  printf ("%s in I/O\n",string);
  1704.       error_protocol ("Unknown name in I/O");
  1705.  
  1706.   }
  1707.    return;
  1708.  
  1709.   }
  1710.   if (t->Kind == kBTP_LIST) {
  1711. # line 1080 "AdaptAnalysis.puma"
  1712.   {
  1713. # line 1081 "AdaptAnalysis.puma"
  1714.    AdaptIOAnalysis (t->BTP_LIST.Elem);
  1715. # line 1082 "AdaptAnalysis.puma"
  1716.    AdaptIOAnalysis (t->BTP_LIST.Next);
  1717.   }
  1718.    return;
  1719.  
  1720.   }
  1721.   if (t->Kind == kBTP_EMPTY) {
  1722. # line 1085 "AdaptAnalysis.puma"
  1723.    return;
  1724.  
  1725.   }
  1726.   if (t->Kind == kVAR_PARAM) {
  1727. # line 1088 "AdaptAnalysis.puma"
  1728.   {
  1729. # line 1090 "AdaptAnalysis.puma"
  1730.  dist = TreeDistribution (t->VAR_PARAM.V);
  1731.       if ( (dist == 1) && (TreeRank (t->VAR_PARAM.V) != 0) )
  1732.        {
  1733.          error_protocol ("distributed array expression in I/O not allowed\n");
  1734.          tree_protocol ("array parameter is ", t->VAR_PARAM.V);
  1735.        }
  1736.       if (dist == -2)
  1737.        {
  1738.          error_protocol ("illegal distribution for I/O parameter");
  1739.          tree_protocol ("parameter is ", t->VAR_PARAM.V);
  1740.        }
  1741.  
  1742.   }
  1743.    return;
  1744.  
  1745.   }
  1746. # line 1104 "AdaptAnalysis.puma"
  1747.   {
  1748. # line 1105 "AdaptAnalysis.puma"
  1749.    error_analysis ("unknown tree in AdaptIO", t);
  1750.   }
  1751.    return;
  1752.  
  1753. ;
  1754. }
  1755.  
  1756. static void AdaptAnalCall
  1757. # if defined __STDC__ | defined __cplusplus
  1758. (register tTree t, register tDefinitions p)
  1759. # else
  1760. (t, p)
  1761.  register tTree t;
  1762.  register tDefinitions p;
  1763. # endif
  1764. {
  1765. # line 1118 "AdaptAnalysis.puma"
  1766.  
  1767. int len1, len2;
  1768. char string[250];
  1769.  
  1770.   if (t == NoTree) return;
  1771.   if (p == NoDefinitions) return;
  1772.   if (t->Kind == kCALL_STMT) {
  1773.   if (Definitions_IsType (t->CALL_STMT.CALL_ID->PROC_OBJ.Object, kObject)) {
  1774.   if (p->Kind == kProcObject) {
  1775.   if (p->ProcObject.decl->Kind == kPROC_DECL) {
  1776. # line 1123 "AdaptAnalysis.puma"
  1777.   {
  1778. # line 1127 "AdaptAnalysis.puma"
  1779.    AdaptAnalCallParams (t->CALL_STMT.CALL_PARAMS, p->ProcObject.decl->PROC_DECL.FORMALS, p->ProcObject.Declarations);
  1780.   }
  1781.    return;
  1782.  
  1783.   }
  1784.   if (p->ProcObject.decl->Kind == kPROC_PARAM_DECL) {
  1785. # line 1130 "AdaptAnalysis.puma"
  1786.   {
  1787. # line 1133 "AdaptAnalysis.puma"
  1788.    AdaptAnalCallParams (t->CALL_STMT.CALL_PARAMS, p->ProcObject.decl->PROC_PARAM_DECL.FORMAL, p->ProcObject.Declarations);
  1789.   }
  1790.    return;
  1791.  
  1792.   }
  1793.   if (p->ProcObject.decl->Kind == kEXT_PROC_DECL) {
  1794. # line 1136 "AdaptAnalysis.puma"
  1795.   {
  1796. # line 1139 "AdaptAnalysis.puma"
  1797.    AdaptAnalCallParams (t->CALL_STMT.CALL_PARAMS, p->ProcObject.decl->EXT_PROC_DECL.FORMALS, p->ProcObject.Declarations);
  1798.   }
  1799.    return;
  1800.  
  1801.   }
  1802.   }
  1803.   }
  1804.   }
  1805.   if (t->Kind == kFUNC_CALL_EXP) {
  1806.   if (Definitions_IsType (t->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Object, kObject)) {
  1807.   if (p->Kind == kFuncObject) {
  1808.   if (p->FuncObject.decl->Kind == kFUNC_DECL) {
  1809. # line 1142 "AdaptAnalysis.puma"
  1810.   {
  1811. # line 1146 "AdaptAnalysis.puma"
  1812.    AdaptAnalCallParams (t->FUNC_CALL_EXP.FUNC_PARAMS, p->FuncObject.decl->FUNC_DECL.FORMALS, p->FuncObject.Declarations);
  1813.   }
  1814.    return;
  1815.  
  1816.   }
  1817.   }
  1818.   }
  1819.   }
  1820. # line 1149 "AdaptAnalysis.puma"
  1821.   {
  1822. # line 1150 "AdaptAnalysis.puma"
  1823.    obj_error_protocol ("mismatch with formal object", p);
  1824. # line 1151 "AdaptAnalysis.puma"
  1825.    error_analysis ("illegal tree in AdaptAnalCall", t);
  1826.   }
  1827.    return;
  1828.  
  1829. ;
  1830. }
  1831.  
  1832. static void AdaptAnalCallParams
  1833. # if defined __STDC__ | defined __cplusplus
  1834. (register tTree a, register tTree f, register tDefinitions d)
  1835. # else
  1836. (a, f, d)
  1837.  register tTree a;
  1838.  register tTree f;
  1839.  register tDefinitions d;
  1840. # endif
  1841. {
  1842. # line 1162 "AdaptAnalysis.puma"
  1843.  
  1844. tObject Obj;
  1845.  
  1846.   if (a == NoTree) return;
  1847.   if (f == NoTree) return;
  1848.   if (d == NoDefinitions) return;
  1849.   if (a->Kind == kBTP_LIST) {
  1850.   if (f->Kind == kDECL_LIST) {
  1851.   if (f->DECL_LIST.Elem->Kind == kVAR_PARAM_DECL) {
  1852. # line 1166 "AdaptAnalysis.puma"
  1853.   {
  1854. # line 1168 "AdaptAnalysis.puma"
  1855.    AdaptAnalMatchParam (a->BTP_LIST.Elem, GetDeclEntry (f->DECL_LIST.Elem->VAR_PARAM_DECL.Name, d));
  1856. # line 1169 "AdaptAnalysis.puma"
  1857.    AdaptAnalCallParams (a->BTP_LIST.Next, f->DECL_LIST.Next, d);
  1858.   }
  1859.    return;
  1860.  
  1861.   }
  1862.   }
  1863.   }
  1864.   if (a->Kind == kBTP_EMPTY) {
  1865.   if (f->Kind == kDECL_EMPTY) {
  1866. # line 1172 "AdaptAnalysis.puma"
  1867.    return;
  1868.  
  1869.   }
  1870.   }
  1871. # line 1175 "AdaptAnalysis.puma"
  1872.   {
  1873. # line 1176 "AdaptAnalysis.puma"
  1874.    error_analysis ("Cannot compare actual and formal parameters", a);
  1875.   }
  1876.    return;
  1877.  
  1878. ;
  1879. }
  1880.  
  1881. static void AdaptAnalMatchParam
  1882. # if defined __STDC__ | defined __cplusplus
  1883. (register tTree actual, register tDefinitions formal)
  1884. # else
  1885. (actual, formal)
  1886.  register tTree actual;
  1887.  register tDefinitions formal;
  1888. # endif
  1889. {
  1890. # line 1189 "AdaptAnalysis.puma"
  1891.  
  1892. char msg[100];
  1893.  
  1894.   if (actual == NoTree) return;
  1895.   if (formal == NoDefinitions) return;
  1896.   if (actual->Kind == kVAR_PARAM) {
  1897. # line 1193 "AdaptAnalysis.puma"
  1898.  {
  1899.   int dist1;
  1900.   int dist2;
  1901.   {
  1902. # line 1195 "AdaptAnalysis.puma"
  1903.  
  1904. # line 1196 "AdaptAnalysis.puma"
  1905.  
  1906. # line 1198 "AdaptAnalysis.puma"
  1907.    dist1 = TreeDistribution (actual);
  1908. # line 1199 "AdaptAnalysis.puma"
  1909.    dist2 = VarDistribution (formal);
  1910. # line 1201 "AdaptAnalysis.puma"
  1911.  
  1912.  
  1913.       if (dist1 != dist2)
  1914.          { error_protocol ("Mismatch of Distribution in parameter");
  1915.            sprintf (msg, "Distribution of actual parameter = %d : ", dist1);
  1916.            tree_protocol (msg, actual);
  1917.            sprintf (msg, "Distribution of formal parameter = %d : ", dist2);
  1918.            print_protocol (msg);
  1919.          }
  1920.       else if (dist1 == 1)
  1921.          MatchDistributions (actual->VAR_PARAM.V, formal);
  1922.  
  1923.   }
  1924.    return;
  1925.  }
  1926.  
  1927.   }
  1928.   if (actual->Kind == kFUNC_PARAM) {
  1929. # line 1215 "AdaptAnalysis.puma"
  1930.   {
  1931. # line 1216 "AdaptAnalysis.puma"
  1932.    tree_warning_protocol ("function parameters not checked : ", actual);
  1933.   }
  1934.    return;
  1935.  
  1936.   }
  1937.   if (actual->Kind == kPROC_PARAM) {
  1938. # line 1220 "AdaptAnalysis.puma"
  1939.   {
  1940. # line 1221 "AdaptAnalysis.puma"
  1941.    tree_warning_protocol ("subroutine parameters not checked : ", actual);
  1942.   }
  1943.    return;
  1944.  
  1945.   }
  1946. # line 1225 "AdaptAnalysis.puma"
  1947.   {
  1948. # line 1226 "AdaptAnalysis.puma"
  1949.    error_analysis ("illegal tree in AdaptAnalMatchParam", actual);
  1950.   }
  1951.    return;
  1952.  
  1953. ;
  1954. }
  1955.  
  1956. static void MatchDistributions
  1957. # if defined __STDC__ | defined __cplusplus
  1958. (register tTree actual, register tDefinitions formal)
  1959. # else
  1960. (actual, formal)
  1961.  register tTree actual;
  1962.  register tDefinitions formal;
  1963. # endif
  1964. {
  1965. # line 1237 "AdaptAnalysis.puma"
  1966.  
  1967. int i, rank;
  1968. bool ok;
  1969. DistributedDimensions dim1, dim2;
  1970.  
  1971.   if (actual == NoTree) return;
  1972.   if (formal == NoDefinitions) return;
  1973.   if (actual->Kind == kUSED_VAR) {
  1974.   if (actual->USED_VAR.VARNAME->VAR_OBJ.Object->Kind == kVarObject) {
  1975.   if (actual->USED_VAR.VARNAME->VAR_OBJ.Object->VarObject.Dist->Kind == kNodeDistribution) {
  1976.   if (formal->Kind == kVarObject) {
  1977.   if (formal->VarObject.Dist->Kind == kNodeDistribution) {
  1978. # line 1243 "AdaptAnalysis.puma"
  1979.   {
  1980. # line 1249 "AdaptAnalysis.puma"
  1981.  dim1 = actual->USED_VAR.VARNAME->VAR_OBJ.Object->VarObject.Dist->NodeDistribution.dims;
  1982.      dim2 = formal->VarObject.Dist->NodeDistribution.dims;
  1983.      rank = dim1.no_dims;
  1984.      ok   = (rank == dim2.no_dims);
  1985.      if (ok)
  1986.        { for (i = 0; i < rank; i++)
  1987.             ok = ok && (dim1.DimsArray[i] == dim2.DimsArray[i]);
  1988.        }
  1989.      if (!ok)
  1990.        { error_protocol ("different distributions of actual and formal");
  1991.          obj_protocol ("actual is ", actual->USED_VAR.VARNAME->VAR_OBJ.Object);
  1992.          obj_protocol ("formal is ", formal);
  1993.        }
  1994.  
  1995.   }
  1996.    return;
  1997.  
  1998.   }
  1999.   }
  2000.   }
  2001.   }
  2002.   }
  2003.   if (formal->Kind == kVarObject) {
  2004. # line 1265 "AdaptAnalysis.puma"
  2005.   {
  2006. # line 1266 "AdaptAnalysis.puma"
  2007.    error_protocol ("Distributed parameter is not whole array");
  2008. # line 1267 "AdaptAnalysis.puma"
  2009.    obj_error_protocol ("formal parameter is ", formal);
  2010. # line 1268 "AdaptAnalysis.puma"
  2011.    tree_protocol ("actual parameter is ", actual);
  2012.   }
  2013.    return;
  2014.  
  2015.   }
  2016. # line 1271 "AdaptAnalysis.puma"
  2017.   {
  2018. # line 1272 "AdaptAnalysis.puma"
  2019.    error_protocol ("something is wrong in MatchDistributions");
  2020.   }
  2021.    return;
  2022.  
  2023. ;
  2024. }
  2025.  
  2026. static void AnalIntrinsicFunction
  2027. # if defined __STDC__ | defined __cplusplus
  2028. (register tIdent name, register tTree params)
  2029. # else
  2030. (name, params)
  2031.  register tIdent name;
  2032.  register tTree params;
  2033. # endif
  2034. {
  2035. # line 1283 "AdaptAnalysis.puma"
  2036.  
  2037. int no;
  2038.  
  2039.   if (params == NoTree) return;
  2040. # line 1289 "AdaptAnalysis.puma"
  2041.   {
  2042. # line 1290 "AdaptAnalysis.puma"
  2043.    if (! (IntrFuncRed (name) == true)) goto yyL1;
  2044.   {
  2045. # line 1291 "AdaptAnalysis.puma"
  2046.    AnalReductionParameters (params);
  2047.   }
  2048.   }
  2049.    return;
  2050. yyL1:;
  2051.  
  2052.   if (equaltIdent (name, MakeIdent ("MINLOC", 6))) {
  2053. # line 1294 "AdaptAnalysis.puma"
  2054.   {
  2055. # line 1295 "AdaptAnalysis.puma"
  2056.    error_protocol ("MINLOC is not supported until now");
  2057.   }
  2058.    return;
  2059.  
  2060.   }
  2061.   if (equaltIdent (name, MakeIdent ("MAXLOC", 6))) {
  2062. # line 1298 "AdaptAnalysis.puma"
  2063.   {
  2064. # line 1299 "AdaptAnalysis.puma"
  2065.    error_protocol ("MAXLOC is not supported until now");
  2066.   }
  2067.    return;
  2068.  
  2069.   }
  2070.   if (equaltIdent (name, MakeIdent ("SPREAD", 6))) {
  2071. # line 1302 "AdaptAnalysis.puma"
  2072.   {
  2073. # line 1303 "AdaptAnalysis.puma"
  2074.  if (TreeListLength (params) != 3)
  2075.          error_protocol ("SPREAD has not three parameters");
  2076.  
  2077.   }
  2078.    return;
  2079.  
  2080.   }
  2081.   if (equaltIdent (name, MakeIdent ("CSHIFT", 6))) {
  2082. # line 1308 "AdaptAnalysis.puma"
  2083.    return;
  2084.  
  2085.   }
  2086.   if (equaltIdent (name, MakeIdent ("TRANSPOSE", 9))) {
  2087. # line 1312 "AdaptAnalysis.puma"
  2088.    return;
  2089.  
  2090.   }
  2091.   if (equaltIdent (name, MakeIdent ("DOTPRODUCT", 10))) {
  2092. # line 1316 "AdaptAnalysis.puma"
  2093.   {
  2094. # line 1317 "AdaptAnalysis.puma"
  2095.    error_protocol ("DOTPRODUCT is not supported until now");
  2096.   }
  2097.    return;
  2098.  
  2099.   }
  2100.   if (equaltIdent (name, MakeIdent ("MATMUL", 6))) {
  2101. # line 1320 "AdaptAnalysis.puma"
  2102.   {
  2103. # line 1321 "AdaptAnalysis.puma"
  2104.    error_protocol ("MATMUL is not supported until now");
  2105.   }
  2106.    return;
  2107.  
  2108.   }
  2109.   if (equaltIdent (name, MakeIdent ("MERGE", 6))) {
  2110. # line 1324 "AdaptAnalysis.puma"
  2111.    return;
  2112.  
  2113.   }
  2114.   if (equaltIdent (name, MakeIdent ("EOSHIFT", 7))) {
  2115. # line 1328 "AdaptAnalysis.puma"
  2116.   {
  2117. # line 1329 "AdaptAnalysis.puma"
  2118.    error_protocol ("EOSHIFT is not supported until now");
  2119.   }
  2120.    return;
  2121.  
  2122.   }
  2123.   if (equaltIdent (name, MakeIdent ("DIAGONAL", 8))) {
  2124. # line 1332 "AdaptAnalysis.puma"
  2125.   {
  2126. # line 1333 "AdaptAnalysis.puma"
  2127.    error_protocol ("DIAGONAL ist not supported until now");
  2128.   }
  2129.    return;
  2130.  
  2131.   }
  2132.   if (equaltIdent (name, MakeIdent ("PACK", 4))) {
  2133. # line 1336 "AdaptAnalysis.puma"
  2134.   {
  2135. # line 1337 "AdaptAnalysis.puma"
  2136.    error_protocol ("PACK ist not supported until now");
  2137.   }
  2138.    return;
  2139.  
  2140.   }
  2141.   if (equaltIdent (name, MakeIdent ("UNPACK", 6))) {
  2142. # line 1340 "AdaptAnalysis.puma"
  2143.   {
  2144. # line 1341 "AdaptAnalysis.puma"
  2145.    error_protocol ("UNPACK ist not supported until now");
  2146.   }
  2147.    return;
  2148.  
  2149.   }
  2150. # line 1344 "AdaptAnalysis.puma"
  2151.   {
  2152. # line 1345 "AdaptAnalysis.puma"
  2153.    error_protocol ("Unknown intrinsic Function in Analysis");
  2154.   }
  2155.    return;
  2156.  
  2157. ;
  2158. }
  2159.  
  2160. static void AnalReductionParameters
  2161. # if defined __STDC__ | defined __cplusplus
  2162. (register tTree params)
  2163. # else
  2164. (params)
  2165.  register tTree params;
  2166. # endif
  2167. {
  2168.   if (params == NoTree) return;
  2169.   if (params->Kind == kBTP_LIST) {
  2170.   if (params->BTP_LIST.Next->Kind == kBTP_EMPTY) {
  2171. # line 1350 "AdaptAnalysis.puma"
  2172.    return;
  2173.  
  2174.   }
  2175.   if (params->BTP_LIST.Next->Kind == kBTP_LIST) {
  2176.   if (params->BTP_LIST.Next->BTP_LIST.Next->Kind == kBTP_EMPTY) {
  2177. # line 1353 "AdaptAnalysis.puma"
  2178.  {
  2179.   bool found;
  2180.   int idim;
  2181.   {
  2182. # line 1355 "AdaptAnalysis.puma"
  2183.    if (! (TreeRank (params->BTP_LIST.Next->BTP_LIST.Elem) == 0)) goto yyL2;
  2184.   {
  2185. # line 1357 "AdaptAnalysis.puma"
  2186.  
  2187. # line 1358 "AdaptAnalysis.puma"
  2188.  
  2189. # line 1360 "AdaptAnalysis.puma"
  2190.  GetIntConstValue (params->BTP_LIST.Next->BTP_LIST.Elem, &found, &idim);
  2191.       if (!found)
  2192.          error_protocol ("dim of reduction must be known at compile time");
  2193.       if ((idim < 1) || (idim > TreeRank (params->BTP_LIST.Elem)) )
  2194.          error_protocol ("dim of reduction is illegal");
  2195.  
  2196.   }
  2197.   }
  2198.    return;
  2199.  }
  2200. yyL2:;
  2201.  
  2202.   }
  2203.   }
  2204.   }
  2205. # line 1368 "AdaptAnalysis.puma"
  2206.   {
  2207. # line 1369 "AdaptAnalysis.puma"
  2208.    error_protocol ("not supported use of reduction");
  2209. # line 1370 "AdaptAnalysis.puma"
  2210.    print_protocol ("mask is not allowed, dim must be known at compile time");
  2211.   }
  2212.    return;
  2213.  
  2214. ;
  2215. }
  2216.  
  2217. static void AnalIntrinsicSubroutine
  2218. # if defined __STDC__ | defined __cplusplus
  2219. (register tIdent name, register tTree params)
  2220. # else
  2221. (name, params)
  2222.  register tIdent name;
  2223.  register tTree params;
  2224. # endif
  2225. {
  2226.   if (params == NoTree) return;
  2227.   if (equaltIdent (name, MakeIdent ("CMF_RANDOM", 10))) {
  2228. # line 1383 "AdaptAnalysis.puma"
  2229.   {
  2230. # line 1384 "AdaptAnalysis.puma"
  2231.    AdaptAnalRandomParams (params);
  2232.   }
  2233.    return;
  2234.  
  2235.   }
  2236.   if (equaltIdent (name, MakeIdent ("CMF_RANDOMIZE", 13))) {
  2237. # line 1387 "AdaptAnalysis.puma"
  2238.   {
  2239. # line 1388 "AdaptAnalysis.puma"
  2240.    AdaptAnalTimerParams (params);
  2241.   }
  2242.    return;
  2243.  
  2244.   }
  2245.   if (equaltIdent (name, MakeIdent ("WALLTIME", 8))) {
  2246. # line 1391 "AdaptAnalysis.puma"
  2247.   {
  2248. # line 1392 "AdaptAnalysis.puma"
  2249.    AdaptAnalTimerParams (params);
  2250.   }
  2251.    return;
  2252.  
  2253.   }
  2254.   if (equaltIdent (name, MakeIdent ("CM_TIMER_CLEAR", 14))) {
  2255. # line 1395 "AdaptAnalysis.puma"
  2256.   {
  2257. # line 1396 "AdaptAnalysis.puma"
  2258.    AdaptAnalTimerParams (params);
  2259.   }
  2260.    return;
  2261.  
  2262.   }
  2263.   if (equaltIdent (name, MakeIdent ("CM_TIMER_PRINT", 14))) {
  2264. # line 1399 "AdaptAnalysis.puma"
  2265.   {
  2266. # line 1400 "AdaptAnalysis.puma"
  2267.    AdaptAnalTimerParams (params);
  2268.   }
  2269.    return;
  2270.  
  2271.   }
  2272.   if (equaltIdent (name, MakeIdent ("CM_TIMER_START", 14))) {
  2273. # line 1403 "AdaptAnalysis.puma"
  2274.   {
  2275. # line 1404 "AdaptAnalysis.puma"
  2276.    AdaptAnalTimerParams (params);
  2277.   }
  2278.    return;
  2279.  
  2280.   }
  2281.   if (equaltIdent (name, MakeIdent ("CM_TIMER_STOP", 13))) {
  2282. # line 1407 "AdaptAnalysis.puma"
  2283.   {
  2284. # line 1408 "AdaptAnalysis.puma"
  2285.    AdaptAnalTimerParams (params);
  2286.   }
  2287.    return;
  2288.  
  2289.   }
  2290.   if (equaltIdent (name, MakeIdent ("GLOBAL_GET", 10))) {
  2291. # line 1411 "AdaptAnalysis.puma"
  2292.   {
  2293. # line 1412 "AdaptAnalysis.puma"
  2294.    AdaptAnalGlobalGetParams (params);
  2295.   }
  2296.    return;
  2297.  
  2298.   }
  2299.   if (equaltIdent (name, MakeIdent ("GLOBAL_SEND", 11))) {
  2300. # line 1415 "AdaptAnalysis.puma"
  2301.   {
  2302. # line 1416 "AdaptAnalysis.puma"
  2303.    AdaptAnalGlobalSendParams (params);
  2304.   }
  2305.    return;
  2306.  
  2307.   }
  2308. # line 1419 "AdaptAnalysis.puma"
  2309.   {
  2310. # line 1420 "AdaptAnalysis.puma"
  2311.    error_protocol ("Unknown intrinsic Subroutine in Analysis");
  2312.   }
  2313.    return;
  2314.  
  2315. ;
  2316. }
  2317.  
  2318. static void AdaptAnalReduceParams
  2319. # if defined __STDC__ | defined __cplusplus
  2320. (register tTree t)
  2321. # else
  2322. (t)
  2323.  register tTree t;
  2324. # endif
  2325. {
  2326.   if (t == NoTree) return;
  2327.   if (t->Kind == kBTP_EMPTY) {
  2328. # line 1431 "AdaptAnalysis.puma"
  2329.    return;
  2330.  
  2331.   }
  2332.   if (t->Kind == kBTP_LIST) {
  2333.   if (t->BTP_LIST.Next->Kind == kBTP_LIST) {
  2334. # line 1434 "AdaptAnalysis.puma"
  2335.   {
  2336. # line 1435 "AdaptAnalysis.puma"
  2337.  if (TreeDistribution (t->BTP_LIST.Elem) != 0)
  2338.        { error_protocol ("REDUCE variable must be replicated");
  2339.          tree_protocol ("REDUCE variable is : ", t->BTP_LIST.Elem);
  2340.        }
  2341.  
  2342. # line 1440 "AdaptAnalysis.puma"
  2343.    AdaptAnalReduceParams (t->BTP_LIST.Next->BTP_LIST.Next);
  2344.   }
  2345.    return;
  2346.  
  2347.   }
  2348.   }
  2349. ;
  2350. }
  2351.  
  2352. static void AdaptAnalTimerParams
  2353. # if defined __STDC__ | defined __cplusplus
  2354. (register tTree t)
  2355. # else
  2356. (t)
  2357.  register tTree t;
  2358. # endif
  2359. {
  2360.   if (t == NoTree) return;
  2361.   if (t->Kind == kBTP_LIST) {
  2362.   if (t->BTP_LIST.Elem->Kind == kVAR_PARAM) {
  2363.   if (t->BTP_LIST.Next->Kind == kBTP_EMPTY) {
  2364. # line 1453 "AdaptAnalysis.puma"
  2365.   {
  2366. # line 1455 "AdaptAnalysis.puma"
  2367.  if (TreeDistribution (t->BTP_LIST.Elem) != 0)
  2368.        error_protocol ("Timer Parameter must be replicated");
  2369.  
  2370.   }
  2371.    return;
  2372.  
  2373.   }
  2374.   }
  2375.   }
  2376. ;
  2377. }
  2378.  
  2379. static void AdaptAnalRandomParams
  2380. # if defined __STDC__ | defined __cplusplus
  2381. (register tTree t)
  2382. # else
  2383. (t)
  2384.  register tTree t;
  2385. # endif
  2386. {
  2387.   if (t == NoTree) return;
  2388.   if (t->Kind == kBTP_LIST) {
  2389.   if (t->BTP_LIST.Elem->Kind == kVAR_PARAM) {
  2390. # line 1470 "AdaptAnalysis.puma"
  2391.   {
  2392. # line 1471 "AdaptAnalysis.puma"
  2393.  t->BTP_LIST.Elem->VAR_PARAM.V = MakeFullShape (t->BTP_LIST.Elem->VAR_PARAM.V);
  2394. # line 1472 "AdaptAnalysis.puma"
  2395.    if (! ((IsContiguousSection (t->BTP_LIST.Elem->VAR_PARAM.V) == false))) goto yyL1;
  2396.   {
  2397. # line 1473 "AdaptAnalysis.puma"
  2398.    error_protocol ("CMF_RANDOM: array must be contiguous");
  2399.   }
  2400.   }
  2401.    return;
  2402. yyL1:;
  2403.  
  2404.   }
  2405.   }
  2406. ;
  2407. }
  2408.  
  2409. static void AdaptAnalGlobalGetParams
  2410. # if defined __STDC__ | defined __cplusplus
  2411. (register tTree parameter_list)
  2412. # else
  2413. (parameter_list)
  2414.  register tTree parameter_list;
  2415. # endif
  2416. {
  2417.   if (parameter_list == NoTree) return;
  2418. # line 1492 "AdaptAnalysis.puma"
  2419.   {
  2420. # line 1493 "AdaptAnalysis.puma"
  2421.    if (! ((DistributedParameters (parameter_list) == false))) goto yyL1;
  2422.   {
  2423. # line 1494 "AdaptAnalysis.puma"
  2424.    if (! ((ReplicatedParameters (parameter_list) == false))) goto yyL1;
  2425.   {
  2426. # line 1496 "AdaptAnalysis.puma"
  2427.    error_protocol ("all parameters of global get must be distributed or replicated");
  2428.   }
  2429.   }
  2430.   }
  2431.    return;
  2432. yyL1:;
  2433.  
  2434. # line 1499 "AdaptAnalysis.puma"
  2435.  {
  2436.   int b_rank;
  2437.   tTree A;
  2438.   tTree B;
  2439.   tTree indexes;
  2440.   tTree M;
  2441.   {
  2442. # line 1501 "AdaptAnalysis.puma"
  2443.  
  2444. # line 1502 "AdaptAnalysis.puma"
  2445.  
  2446. # line 1503 "AdaptAnalysis.puma"
  2447.  
  2448. # line 1504 "AdaptAnalysis.puma"
  2449.  
  2450. # line 1505 "AdaptAnalysis.puma"
  2451.  
  2452. # line 1507 "AdaptAnalysis.puma"
  2453.  SplitGet (parameter_list,&b_rank, &A, &B, &indexes, &M);
  2454.  
  2455.  
  2456.  
  2457.      CheckAlignedIndexes (A, indexes, b_rank);
  2458.  
  2459.  
  2460.  
  2461.      if (M != NoTree)
  2462.         CheckAlignedMask (A, M);
  2463.  
  2464.   }
  2465.    return;
  2466.  }
  2467.  
  2468. ;
  2469. }
  2470.  
  2471. static void AdaptAnalGlobalSendParams
  2472. # if defined __STDC__ | defined __cplusplus
  2473. (register tTree parameter_list)
  2474. # else
  2475. (parameter_list)
  2476.  register tTree parameter_list;
  2477. # endif
  2478. {
  2479.   if (parameter_list == NoTree) return;
  2480. # line 1522 "AdaptAnalysis.puma"
  2481.   {
  2482. # line 1523 "AdaptAnalysis.puma"
  2483.    if (! ((DistributedParameters (parameter_list) == false))) goto yyL1;
  2484.   {
  2485. # line 1524 "AdaptAnalysis.puma"
  2486.    if (! ((ReplicatedParameters (parameter_list) == false))) goto yyL1;
  2487.   {
  2488. # line 1526 "AdaptAnalysis.puma"
  2489.    error_protocol ("all parameters of global send must be distributed or replicated");
  2490.   }
  2491.   }
  2492.   }
  2493.    return;
  2494. yyL1:;
  2495.  
  2496. # line 1529 "AdaptAnalysis.puma"
  2497.  {
  2498.   int b_rank;
  2499.   tTree A;
  2500.   tTree B;
  2501.   tTree indexes;
  2502.   tTree M;
  2503.   tTree op;
  2504.   {
  2505. # line 1531 "AdaptAnalysis.puma"
  2506.  
  2507. # line 1532 "AdaptAnalysis.puma"
  2508.  
  2509. # line 1533 "AdaptAnalysis.puma"
  2510.  
  2511. # line 1534 "AdaptAnalysis.puma"
  2512.  
  2513. # line 1535 "AdaptAnalysis.puma"
  2514.  
  2515. # line 1536 "AdaptAnalysis.puma"
  2516.  
  2517. # line 1538 "AdaptAnalysis.puma"
  2518.  SplitSend (parameter_list, &b_rank, &A, &B, &indexes, &M, &op);
  2519.  
  2520.  
  2521.  
  2522.      CheckAlignedIndexes (A, indexes, b_rank);
  2523.  
  2524.  
  2525.      if (M != NoTree)
  2526.         CheckAlignedMask (A, M);
  2527.  
  2528.   }
  2529.    return;
  2530.  }
  2531.  
  2532. ;
  2533. }
  2534.  
  2535. static bool DistributedParameters
  2536. # if defined __STDC__ | defined __cplusplus
  2537. (register tTree plist)
  2538. # else
  2539. (plist)
  2540.  register tTree plist;
  2541. # endif
  2542. {
  2543.   if (plist == NoTree) return false;
  2544.   if (plist->Kind == kBTP_LIST) {
  2545.   if (plist->BTP_LIST.Elem->Kind == kVAR_PARAM) {
  2546.   if (plist->BTP_LIST.Elem->VAR_PARAM.V->Kind == kUSED_VAR) {
  2547. # line 1560 "AdaptAnalysis.puma"
  2548.   {
  2549. # line 1561 "AdaptAnalysis.puma"
  2550.    if (! (TreeDistribution (plist->BTP_LIST.Elem->VAR_PARAM.V->USED_VAR.VARNAME) == 1)) goto yyL1;
  2551.   {
  2552. # line 1562 "AdaptAnalysis.puma"
  2553.    if (! (DistributedParameters (plist->BTP_LIST.Next))) goto yyL1;
  2554.   }
  2555.   }
  2556.    return true;
  2557. yyL1:;
  2558.  
  2559.   }
  2560.   }
  2561.   if (plist->BTP_LIST.Elem->Kind == kFUNC_PARAM) {
  2562.   if (plist->BTP_LIST.Next->Kind == kBTP_EMPTY) {
  2563. # line 1565 "AdaptAnalysis.puma"
  2564.    return true;
  2565.  
  2566.   }
  2567.   }
  2568.   }
  2569.   if (plist->Kind == kBTP_EMPTY) {
  2570. # line 1569 "AdaptAnalysis.puma"
  2571.    return true;
  2572.  
  2573.   }
  2574.   return false;
  2575. }
  2576.  
  2577. static bool ReplicatedParameters
  2578. # if defined __STDC__ | defined __cplusplus
  2579. (register tTree plist)
  2580. # else
  2581. (plist)
  2582.  register tTree plist;
  2583. # endif
  2584. {
  2585.   if (plist == NoTree) return false;
  2586.   if (plist->Kind == kBTP_LIST) {
  2587.   if (plist->BTP_LIST.Elem->Kind == kVAR_PARAM) {
  2588.   if (plist->BTP_LIST.Elem->VAR_PARAM.V->Kind == kUSED_VAR) {
  2589. # line 1582 "AdaptAnalysis.puma"
  2590.   {
  2591. # line 1583 "AdaptAnalysis.puma"
  2592.    if (! (TreeDistribution (plist->BTP_LIST.Elem->VAR_PARAM.V->USED_VAR.VARNAME) == 0)) goto yyL1;
  2593.   {
  2594. # line 1584 "AdaptAnalysis.puma"
  2595.    if (! (ReplicatedParameters (plist->BTP_LIST.Next))) goto yyL1;
  2596.   }
  2597.   }
  2598.    return true;
  2599. yyL1:;
  2600.  
  2601.   }
  2602.   }
  2603.   if (plist->BTP_LIST.Elem->Kind == kFUNC_PARAM) {
  2604.   if (plist->BTP_LIST.Next->Kind == kBTP_EMPTY) {
  2605. # line 1587 "AdaptAnalysis.puma"
  2606.    return true;
  2607.  
  2608.   }
  2609.   }
  2610.   }
  2611.   if (plist->Kind == kBTP_EMPTY) {
  2612. # line 1591 "AdaptAnalysis.puma"
  2613.    return true;
  2614.  
  2615.   }
  2616.   return false;
  2617. }
  2618.  
  2619. static void CheckAlignedIndexes
  2620. # if defined __STDC__ | defined __cplusplus
  2621. (register tTree a, register tTree indexlist, register int n)
  2622. # else
  2623. (a, indexlist, n)
  2624.  register tTree a;
  2625.  register tTree indexlist;
  2626.  register int n;
  2627. # endif
  2628. {
  2629.   if (a == NoTree) return;
  2630.   if (indexlist == NoTree) return;
  2631.   if (equalint (n, 0)) {
  2632. # line 1603 "AdaptAnalysis.puma"
  2633.    return;
  2634.  
  2635.   }
  2636.   if (indexlist->Kind == kBTP_LIST) {
  2637.   if (indexlist->BTP_LIST.Elem->Kind == kVAR_PARAM) {
  2638. # line 1606 "AdaptAnalysis.puma"
  2639.   {
  2640. # line 1607 "AdaptAnalysis.puma"
  2641.  if (CountMovements (a, indexlist->BTP_LIST.Elem->VAR_PARAM.V) > 0)
  2642.         { error_protocol ("index must be local/aligned to A");
  2643.           tree_protocol ("index is ", indexlist->BTP_LIST.Elem->VAR_PARAM.V);
  2644.           tree_protocol ("must be aligned to ", a);
  2645.         }
  2646.  
  2647. # line 1613 "AdaptAnalysis.puma"
  2648.    CheckAlignedIndexes (a, indexlist->BTP_LIST.Next, n - 1);
  2649.   }
  2650.    return;
  2651.  
  2652.   }
  2653.   }
  2654. ;
  2655. }
  2656.  
  2657. static void CheckAlignedMask
  2658. # if defined __STDC__ | defined __cplusplus
  2659. (register tTree a, register tTree mask)
  2660. # else
  2661. (a, mask)
  2662.  register tTree a;
  2663.  register tTree mask;
  2664. # endif
  2665. {
  2666.   if (a == NoTree) return;
  2667.   if (mask == NoTree) return;
  2668. # line 1618 "AdaptAnalysis.puma"
  2669.   {
  2670. # line 1619 "AdaptAnalysis.puma"
  2671.  if (CountMovements (a, mask) > 0)
  2672.         { error_protocol ("mask is not local/aligned to A");
  2673.           tree_protocol ("mask is ", mask);
  2674.         }
  2675.  
  2676.   }
  2677.    return;
  2678.  
  2679. ;
  2680. }
  2681.  
  2682. static void CheckCommons
  2683. # if defined __STDC__ | defined __cplusplus
  2684. (register tDefinitions t)
  2685. # else
  2686. (t)
  2687.  register tDefinitions t;
  2688. # endif
  2689. {
  2690.   if (t == NoDefinitions) return;
  2691.   if (t->Kind == kENTRY_LIST) {
  2692. # line 1638 "AdaptAnalysis.puma"
  2693.   {
  2694. # line 1639 "AdaptAnalysis.puma"
  2695.    CheckCommons (t->ENTRY_LIST.Next);
  2696. # line 1640 "AdaptAnalysis.puma"
  2697.    CheckCommons (t->ENTRY_LIST.Elem);
  2698.   }
  2699.    return;
  2700.  
  2701.   }
  2702.   if (t->Kind == kENTRY_EMPTY) {
  2703. # line 1643 "AdaptAnalysis.puma"
  2704.    return;
  2705.  
  2706.   }
  2707.   if (t->Kind == kCommonObject) {
  2708. # line 1646 "AdaptAnalysis.puma"
  2709.   {
  2710. # line 1647 "AdaptAnalysis.puma"
  2711.    if (! ((t->CommonObject.sequence == 1))) goto yyL3;
  2712.   {
  2713. # line 1648 "AdaptAnalysis.puma"
  2714.    if (! ((t->CommonObject.distributed_vars > 0))) goto yyL3;
  2715.   {
  2716. # line 1650 "AdaptAnalysis.puma"
  2717.    tree_error_protocol ("SEQUENCE association for COMMON with distributed vars", t->CommonObject.decl);
  2718.   }
  2719.   }
  2720.   }
  2721.    return;
  2722. yyL3:;
  2723.  
  2724. # line 1653 "AdaptAnalysis.puma"
  2725.   {
  2726. # line 1655 "AdaptAnalysis.puma"
  2727.    if (! ((t->CommonObject.main != true))) goto yyL4;
  2728.   {
  2729. # line 1659 "AdaptAnalysis.puma"
  2730.    if (! ((t->CommonObject.distributed_vars > 0))) goto yyL4;
  2731.   {
  2732. # line 1661 "AdaptAnalysis.puma"
  2733.    tree_error_protocol ("COMMON with distributed variables not defined in main", t->CommonObject.decl);
  2734.   }
  2735.   }
  2736.   }
  2737.    return;
  2738. yyL4:;
  2739.  
  2740.   }
  2741. ;
  2742. }
  2743.  
  2744. void BeginAdaptAnalysis ()
  2745. {
  2746. }
  2747.  
  2748. void CloseAdaptAnalysis ()
  2749. {
  2750. }
  2751.